Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Memory Functions and Macros

Detailed Description

This is a group of memory management macros and functions. Using macros for working with memory allows several useful things to be implemented. Instrumentation can be performed, different function names or parameters can be rearranged through the macro, and larger blocks of code can be expanded that check whether an allocation is even necessary. The phDALLOC family of macros take more arguments than the general purpose phMemcpy/phMemmove/phCalloc/phMalloc/phRealloc macros. These arguments are used to check how large the memory is and whether more/less memory needs to be allocated and can prevent the call to the memory allocation system.


 Dynamic Memory Allocation Macros


#define phMemset(dst, v, size)   memset(dst,v,size)
#define phMemcpy(dst, src, size)   memcpy(dst,src,size)
#define phMemmove(dst, src, size)   memmove(dst,src,size)
#define phCalloc(nmemb, size)   calloc(nmemb, size)
#define phMalloc(size)   bfin_malloc(size)
#define phRealloc(ptr, size)   bfin_realloc(ptr, size)
#define phFree(x)   { if (x) { free(x); x = NULL; } }
#define phDelete(x)   { if (x) { delete x; x = NULL; } }
#define phDeletearr(x)   { if (x) { delete [] x; x = NULL; } }
#define phDeleteArray   phDeletearr


typedef void *(* ph_calloc_func )(size_t nmemb, size_t size)
typedef void *(* ph_malloc_func )(size_t size)
typedef void *(* ph_realloc_func )(void *ptr, size_t size)


void * bfin_realloc (void *ptr, size_t size)
void * bfin_malloc (size_t size)

Copyright (C) 2002 - 2007 Philip D.S. Thoren ( )
University Of Massachusetts at Lowell
Robotics Lab Logo

Generated on Sat Jun 16 02:45:27 2007 for phission by  doxygen 1.4.4