[ Home ]

memory.h File Reference

Memory allocation manager. More...

#include <stdlib.h>
#include "../common/platform.h"
#include "../common/common_utils.h"

Include dependency graph for memory.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MM_MALLOC(size)   Memory_malloc( (size) )
#define MM_CALLOC(num, size)   Memory_calloc( (num), (size) )
#define MM_REALLOC(memblock, size)   Memory_realloc( (memblock), (size) )
#define MM_FREE(memblock)   { Memory_free( (memblock) ); ((memblock)) = NULL; }
#define MM_OUTOFMEM(name)   Memory_outofmem( (name), __FILE__, __LINE__ )
#define MM_MEMCPY   memcpy

Functions

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


Detailed Description

Memory allocation manager.

Author:
Michael Liebscher
Date:
2004

Function Documentation

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.

void Memory_free ( void *  memblock  ) 

Deallocates or frees a memory block.

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

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.

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.

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.