[ Home ]

memory.c File Reference

Memory allocation module. More...

#include <stdlib.h>
#include <stdio.h>
#include "memory.h"

Include dependency graph for memory.c:


Defines

#define PARANOID   0

Functions

PUBLIC void * Memory_malloc (size_t size)
 Allocates memory blocks.
PUBLIC void * Memory_calloc (size_t num, size_t size)
 Allocates an array in memory with elements initialized to 0.
PUBLIC void * Memory_realloc (void *memblock, size_t size)
 Reallocate memory blocks.
PUBLIC void Memory_free (void *memblock)
 Deallocates or frees a memory block.
PUBLIC void Memory_outofmem (const char *name, const char *file, W32 line)
 Print message out of memory.

Detailed Description

Memory allocation module.

Author:
Michael Liebscher
Date:
2004

Function Documentation

PUBLIC void* Memory_calloc ( size_t  num,
size_t  size 
)

Allocates an array in memory with elements initialized to 0.

Parameters:
[in] num Number of elements.
[in] size Bytes to allocate.
Returns:
Void pointer to the allocated space on success, or NULL if there is insufficient memory available.

PUBLIC void Memory_free ( void *  memblock  ) 

Deallocates or frees a memory block.

Parameters:
[in] memblock Previously allocated memory block to be freed.
Returns:
Nothing.

PUBLIC void* Memory_malloc ( size_t  size  ) 

Allocates memory blocks.

Parameters:
[in] size Bytes to allocate.
Returns:
Void pointer to the allocated space on success, or NULL if there is insufficient memory available.

PUBLIC void Memory_outofmem ( const char *  name,
const char *  file,
W32  line 
)

Print message out of memory.

Parameters:
[in] name Name of function this occurred in.
[in] file File name that this occurred in.
[in] line Line number this occurred on.
Returns:
Nothing.

PUBLIC void* Memory_realloc ( void *  memblock,
size_t  size 
)

Reallocate memory blocks.

Parameters:
[in] memblock Pointer to previously allocated memory block.
[in] size Bytes to allocate.
Returns:
A void pointer to the reallocated (and possibly moved) memory block. The return value is NULL if the size is zero and the buffer argument is not NULL, or if there is not enough available memory to expand the block to the given size.