/* * Allocate some memory */ void* ralloc(size_t len) { void *mem; /* Allow allocation of "zero bytes" */ if (len == 0) return (NULL); /* Use the aux function if set */ if (ralloc_aux) mem = (*ralloc_aux)(len); /* Use malloc() to allocate some memory */ else mem = malloc(len); /* We were able to acquire memory */ if (!mem) mem = rpanic(len); /* Return the memory, if any */ return (mem); }
/* * Allocate some memory */ vptr ralloc(huge len) { vptr mem; /* Allow allocation of "zero bytes" */ if (len == 0) return ((vptr)(NULL)); /* Use the aux function if set */ if (ralloc_aux) mem = (*ralloc_aux)(len); /* Use malloc() to allocate some memory */ else mem = ((vptr)(malloc((size_t)(len)))); /* We were able to acquire memory */ if (!mem) mem = rpanic(len); /* Return the memory, if any */ return (mem); }