--- ray/src/meta/palloc.c 2003/02/22 02:07:26 1.1 +++ ray/src/meta/palloc.c 2003/11/15 02:13:37 1.4 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: palloc.c,v 1.1 2003/02/22 02:07:26 greg Exp $"; +static const char RCSid[] = "$Id: palloc.c,v 1.4 2003/11/15 02:13:37 schorsch Exp $"; #endif /* * Limited dynamic storage allocator for primitives @@ -9,55 +9,47 @@ static const char RCSid[] = "$Id: palloc.c,v 1.1 2003/ #define FBSIZE 72 /* size of malloc call */ - - - #include "meta.h" +#include "rtio.h" - - - extern int maxalloc; /* number of prims to allocate */ - int nalloc = 0; /* number allocated so far */ - - static PLIST freelist = {NULL, NULL}; +static int morefree(void); PRIMITIVE * -palloc() /* allocate a primitive */ +palloc(void) /* allocate a primitive */ { - register PRIMITIVE *p; + register PRIMITIVE *p; - if (maxalloc > 0 && nalloc >= maxalloc) - return(NULL); + if (maxalloc > 0 && nalloc >= maxalloc) + return(NULL); - if ((p = pop(&freelist)) == NULL) - if (morefree()) - p = pop(&freelist); - else { - sprintf(errmsg, "out of memory in palloc (nalloc = %d)", nalloc); - error(SYSTEM, errmsg); - } + if ((p = pop(&freelist)) == NULL) { + if (morefree()) + p = pop(&freelist); + else { + sprintf(errmsg, "out of memory in palloc (nalloc = %d)", nalloc); + error(SYSTEM, errmsg); + } + } - nalloc++; - return(p); - } + nalloc++; + return(p); +} - - -pfree(p) /* free a primitive */ - -register PRIMITIVE *p; - +void +pfree( /* free a primitive */ +register PRIMITIVE *p +) { if (p->args != NULL) { @@ -71,11 +63,10 @@ register PRIMITIVE *p; - -plfree(pl) /* free a primitive list */ - -register PLIST *pl; - +void +plfree( /* free a primitive list */ +register PLIST *pl +) { register PRIMITIVE *p; @@ -94,10 +85,8 @@ register PLIST *pl; - - static int -morefree() /* get more free space */ +morefree(void) /* get more free space */ { register PRIMITIVE *p;