Main Page | Class List | File List | Class Members | File Members | Related Pages

memory.h File Reference

Simple wrappers for the C libraries allocation functions. More...

Go to the source code of this file.

Defines

#define CALLOC(nmemb, size)   gift_calloc(nmemb,size)
#define MALLOC(size)   CALLOC(1,size)
#define NEW(type)   MALLOC(sizeof(type))
#define FREE(ptr)   gift_free(ptr)
#define REALLOC(ptr, size)   gift_realloc(ptr,size)

Functions

EXTERN_C_BEGIN LIBGIFT_EXPORT
void * 
gift_malloc (size_t size)
LIBGIFT_EXPORT void * gift_calloc (size_t nmemb, size_t size)
LIBGIFT_EXPORT void gift_free (void *ptr)
LIBGIFT_EXPORT void * gift_realloc (void *ptr, size_t size)
LIBGIFT_EXPORT void * gift_memdup (const void *ptr, size_t size)


Detailed Description

Simple wrappers for the C libraries allocation functions.


Function Documentation

LIBGIFT_EXPORT void* gift_calloc size_t  nmemb,
size_t  size
 

Wrapper for calloc to prevent nmemb 0 or size 0.

LIBGIFT_EXPORT void gift_free void *  ptr  ) 
 

Dummy wrapper for free to just go along with this scheme.

EXTERN_C_BEGIN LIBGIFT_EXPORT void* gift_malloc size_t  size  ) 
 

Wrapper for malloc that prevents malloc(0).

LIBGIFT_EXPORT void* gift_memdup const void *  ptr,
size_t  size
 

Similar to strdup, except that it operates on raw memory. I'm baffled why such a function was not provided by the standard.

LIBGIFT_EXPORT void* gift_realloc void *  ptr,
size_t  size
 

Realloc wrapper that prevents some broken implementations of realloc from failing when ptr is NULL or size is 0.


Generated on Sun Aug 22 08:07:11 2004 by doxygen 1.3.7