aboutsummaryrefslogtreecommitdiffstats
path: root/node.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2017-01-25 14:58:35 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2017-01-25 14:58:35 -0500
commit6b12d4f726b9578d5c878fa765d5c167c9d71618 (patch)
treea568048349602ff1be7dfd5c439e569e016f9545 /node.c
parent4c19bff0e44c358deb8efacf2cda0dbaf4a45823 (diff)
downloadegawk-6b12d4f726b9578d5c878fa765d5c167c9d71618.tar.gz
egawk-6b12d4f726b9578d5c878fa765d5c167c9d71618.tar.bz2
egawk-6b12d4f726b9578d5c878fa765d5c167c9d71618.zip
Minor rewrite of block allocator to improve clarity.
Diffstat (limited to 'node.c')
-rw-r--r--node.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/node.c b/node.c
index 97f65fa3..f1f80177 100644
--- a/node.c
+++ b/node.c
@@ -1001,32 +1001,33 @@ void init_btowc_cache()
#define BLOCKCHUNK 100
-BLOCK nextfree[BLOCK_MAX] = {
- { 0, NULL}, /* invalid */
- { sizeof(NODE), NULL },
- { sizeof(BUCKET), NULL },
+struct block_header nextfree[BLOCK_MAX] = {
+ { NULL, 0}, /* invalid */
+ { NULL, sizeof(NODE) },
+ { NULL, sizeof(BUCKET) },
};
/* more_blocks --- get more blocks of memory and add to the free list;
- size of a block must be >= sizeof(BLOCK)
+ size of a block must be >= sizeof(struct block_item)
*/
void *
more_blocks(int id)
{
- BLOCK *freep, *np, *next;
+ struct block_item *freep, *np, *next;
char *p, *endp;
size_t size;
size = nextfree[id].size;
- emalloc(freep, BLOCK *, BLOCKCHUNK * size, "more_blocks");
+ assert(size >= sizeof(struct block_item));
+ emalloc(freep, struct block_item *, BLOCKCHUNK * size, "more_blocks");
p = (char *) freep;
endp = p + BLOCKCHUNK * size;
for (np = freep; ; np = next) {
- next = (BLOCK *) (p += size);
+ next = (struct block_item *) (p += size);
if (p >= endp) {
np->freep = NULL;
break;