#include "defs.h" #define SLOP 0100 #define HEAPINC 04000 ADR heapmin, heapmax; /* used for space allocation */ ADR heapnxt; ERR heaperr; heaprnd(s) POS s; { heapnxt += (s+sizeof(ADR))&~(sizeof(ADR)-1); } ADR getheap(s) POS s; { REG POS end; IF heapnxt == nil(ADR) THEN heapmax = heapmin = heapnxt = sbrk(0); FI end = round(heapnxt+s, SLOP); IF adr(end)>=heapmax THEN IF brk(adr(end)+HEAPINC) == adr(-1) THEN longjmp(heaperr, 1); ELSE heapmax=adr(end)+HEAPINC; FI FI return(heapnxt); } ADR heap(s) POS s; { REG ADR r=getheap(s); heaprnd(s); return(r); } ADR setheap(s) ADR s; { return(brk(s)); }