# include "new.h" int New (Type* objptr) int NewArr (Type* arr, size_t array_size) ReSizeArr (Type* oldarr, new_size) New() allocate sizeof(*objptr) zeroed bytes to objptr return ok or err NewArr() allocate sizeof(arr[0])*array_size zeroed bytes to arr return ok or err ReSizeArr() reallocate sizeof(arr[0])*new_size bytes to to arr return ok or err Dispose (ptr) free the space held by ptr Vanity wrappers around malloc/free (or substitute) memory allocation routine to capture a common idiom. The evil of macros are required as these functions would of necessity be generic ie something like template int New(T** p); // Probably not legitimate C++ Examples typedef struct rec {...} REC; REC* record = 0; record = malloc(sizeof(*record)); if (record) { ... becomes REC* record = 0; if (New(record)==ok) { ... and REC* vec = 0; vec = malloc (sizeof(*vec)*n); if (vec) { .... becomes if (NewArr(vec,n)==ok) { ... One common problem they solve for me is my forgetting the element size or getting the size wrong. eg T* rec = malloc(sizeof(rec)) for T* rec = malloc(sizeof(*rec)) T* vec = malloc(n) for T* vec = malloc(sizeof(*vec)*n) The other is forgetting to assign the realloc() memory back to the original pointer - this is hard to spot as it works most of the time as reallocation will often just extend the existing allocation. eg T* nvec = realloc (vec, newsize*sizeof(*vec)); if (nvec) { .... vec = nvec; // forgetting this where if (ReSizeArr (vec, newsize)==ok) { ... takes care of it.