/**ALLOCATE( size -- ptr|0 code )
* allocate a chunk of memory from the system heap.
* use FREE to release the memory area back to the system.
* a code of zero means success.
*/FCode (p4_allocate)
{
errno = 0;
if ((*SP = (p4cell) p4_calloc (1, (size_t) * SP)) != 0)
*--SP = 0;
else *--SP = errno;
}
/**FREE( ptr -- code )
* free the memory from ALLOCATE
* a code of zero means success.
*/FCode (p4_free)
{
errno = 0;
{ p4_xfree (*(void **) SP); }
*SP = errno;
}
/**RESIZE( ptr newsize -- ptr' code )
* resize the system memory chunk.
* a code of zero means success.
*/FCode (p4_resize)
{
void *p;
errno = 0;
p = realloc ((void *) SP[1], (size_t) SP[0]);
if (p == NULL)
{
SP[0] = errno;
}else{
P4_debug2 (14, "realloc %p -> %p", (void*)SP[1], p);
SP[0] = 0;
SP[1] = (p4cell) p;
}
}