aboutsummaryrefslogtreecommitdiffstats
path: root/node.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2019-08-30 10:42:50 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2019-08-30 10:42:50 -0400
commit8cc45af919dc56011dbf4c8965b9c1e4784e56d7 (patch)
treee271f42fbc3de7ce1f1e477e700d769bde2fcca4 /node.c
parentc15d2db3ce7ea49741d8792190f9212842db86ec (diff)
downloadegawk-8cc45af919dc56011dbf4c8965b9c1e4784e56d7.tar.gz
egawk-8cc45af919dc56011dbf4c8965b9c1e4784e56d7.tar.bz2
egawk-8cc45af919dc56011dbf4c8965b9c1e4784e56d7.zip
In .developing mode, define MEMDEBUG to use malloc/free for block allocation to facilitate finding memory leaks.
Diffstat (limited to 'node.c')
-rw-r--r--node.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/node.c b/node.c
index 9574c3e7..eacd17b3 100644
--- a/node.c
+++ b/node.c
@@ -1034,6 +1034,25 @@ struct block_header nextfree[BLOCK_MAX] = {
#endif
};
+#ifdef MEMDEBUG
+
+void *
+r_getblock(int id)
+{
+ void *res;
+ emalloc(res, void *, nextfree[id].size, "getblock");
+ nextfree[id].cnt++;
+ return res;
+}
+
+void
+r_freeblock(void *p, int id)
+{
+ nextfree[id].cnt--;
+ free(p);
+}
+
+#else
/* more_blocks --- get more blocks of memory and add to the free list;
size of a block must be >= sizeof(struct block_item)
@@ -1064,3 +1083,5 @@ more_blocks(int id)
nextfree[id].freep = freep->freep;
return freep;
}
+
+#endif