#include #include "misc.h" void *emalloc(size_t nbytes) { void *p = malloc(nbytes); if (p == NULL) error("out of memory (emalloc(%lu))\n", (unsigned long)nbytes); return p; } void *ecalloc(size_t nelem, size_t elsize) { void *p = calloc(nelem, elsize); if (p == NULL) error("out of memory (ecalloc(%lu,%lu))\n", (unsigned long)nelem, (unsigned long)elsize); return p; } void *erealloc(void *ptr, size_t nbytes) { void *p = realloc(ptr, nbytes); if (nbytes != 0 && p == NULL) error("out of memory (erealloc(%p,%lu))\n", ptr, (unsigned long)nbytes); return p; }