GETMEM(2)
NAME
getmem, getstk − get a block of main memory
SYNOPSIS
char ∗getmem(nbytes)
int nbytes; char ∗getstk(nbytes)
int nbytes;
DESCRIPTION
In either form, getmem rounds the number of bytes, nbytes, to an even-word multiple, and allocates a block of nbytes bytes of memory for the caller. Getmem returns the lowest word address in the allocated block; getstk returns the highest word address in the allocated block. If less than nbytes bytes remain, the call returns SYSERR.
Getmem allocates memory starting with the end of the loaded program. Getstk allocates memory from the stack area downward. The routines cooperate so they never allocate overlapping regions.
SEE ALSO
freemem(2) getbuf(2), freebuf(2)
BUGS
There is no way to protect memory, so the active stack may write into regions returned by either call; allocations returned by getstk are more prone to disaster because they lie closest to the dynamic stack areas of other processes.
December 01, 1986 — Xinu Programmer’s Manual