#include "alloc.h"
Go to the source code of this file.
Functions | |
T* | agent_malloc (T **aa, size_t size) |
T* | agent_realloc (T **aa, size_t size) |
void | agent_free (void *ptr) |
Variables | |
const char | alcid [] = "\100$ Free Agent: alloc.cpp, v 0.1 2002/05/29 red0x Exp $" |
Definition in file alloc.cpp.
|
Free memory This function does C-Style memory de-allocation (free)
Definition at line 78 of file alloc.cpp. 00079 { 00080 {assert(ptr != NULL);} 00081 free(ptr); 00082 ptr = NULL; 00083 } |
|
Allocate memory (Template function) This function does C-Style memory allocation (malloc) and puts it in to a pointer.
Definition at line 34 of file alloc.cpp. 00035 { 00036 {assert(size > 0);} 00037 size_t tmpii = size + SAFE_MEM; 00038 *aa = NULL; 00039 *aa = (T *) malloc(tmpii); 00040 if (*aa == NULL) 00041 return NULL;//exit(-1); 00042 memset(*aa, 0, tmpii); 00043 return *aa; 00044 } |
|
Reallocate memory (Template Function) This function does C-Style memory reallocation (realloc) and puts it in to a pointer.
Definition at line 56 of file alloc.cpp. 00057 { 00058 {assert(size > 0);} 00059 {assert(aa != NULL);} 00060 unsigned long kk, tmpqq = size + SAFE_MEM; 00061 size_t tmpii = sizeof(T) * (tmpqq); 00062 *aa = (T *) realloc(*aa, tmpii); 00063 if (*aa == NULL) 00064 return NULL;//exit(-1); 00065 // do not memset memset(aa, 0, tmpii); 00066 *aa[tmpqq-1] = 0x00; //NULL terminator... 00067 for (kk = size; kk < tmpqq; kk++) 00068 *aa[kk] = 0; // a few NULL terminators, for safety 00069 return *aa; 00070 } |
|
|