diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-02 15:49:42 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-02 15:49:42 +0300 |
commit | 483a58b779f2bd6c5fff64c9429a766d33e46a41 (patch) | |
tree | 41ee58e21c390c40d90893b277542b309e7d0de7 /awka.c | |
parent | 3711eedc1b995eb1926c9ffb902d5d796cacf8d0 (diff) | |
download | egawk-483a58b779f2bd6c5fff64c9429a766d33e46a41.tar.gz egawk-483a58b779f2bd6c5fff64c9429a766d33e46a41.tar.bz2 egawk-483a58b779f2bd6c5fff64c9429a766d33e46a41.zip |
Now at 2.03.
Diffstat (limited to 'awka.c')
-rw-r--r-- | awka.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -0,0 +1,44 @@ +/* + * some speciallized memory allocation routines + * + * $Log: awka.c,v $ + * Revision 1.1 89/03/22 21:04:00 david + * Initial revision + * + */ + +#include "awk.h" + +#define NODECHUNK 50 + +NODE *nextfree = NULL; +NODE *lastfree = NULL; + +NODE * +newnode(ty) +NODETYPE ty; +{ + NODE *it; + NODE *np; + + if (nextfree == lastfree) { + emalloc(nextfree, NODE *, NODECHUNK * sizeof(NODE), "newnode"); + for (np = nextfree; np < &nextfree[NODECHUNK - 1]; np++) + np->nextp = np + 1; + np->nextp = lastfree; + lastfree = np; + } + it = nextfree; + nextfree = nextfree->nextp; + it->type = ty; + it->flags = MALLOC; + return it; +} + +freenode(it) +NODE *it; +{ + lastfree->nextp = it; + it->nextp = NULL; + lastfree = it; +} |