7 * A memory allocator that aborts on failure (so that the caller never
8 * needs to handle out of memory, which we assume is very unlikely to
9 * happen under normal circumstances on any modern machine).
11 void *mem_alloc(size_t nmemb,size_t size)
13 void *ptr=malloc(nmemb*size);
17 "Not enough memory to allocate %lu elements of %lu bytes.\n",
18 (unsigned long)nmemb,(unsigned long)size);
25 * As mem_new, but new memory is cleared to zero.
27 void *mem_alloc0(size_t nmemb,size_t size)
29 void *ptr=calloc(nmemb,size);
33 "Not enough memory to allocate %lu elements of %lu bytes.\n",
34 (unsigned long)nmemb,(unsigned long)size);
41 * Grow or shrink a memory block, aborting on failure.
43 void *mem_realloc(void *ptr,size_t nmemb,size_t size)
45 ptr=realloc(ptr,nmemb*size);
49 "Not enough memory to allocate %lu elements of %lu bytes.\n",
50 (unsigned long)nmemb,(unsigned long)size);