[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-3818-g8cc45a
From: |
Andrew J. Schorr |
Subject: |
[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-3818-g8cc45af |
Date: |
Fri, 30 Aug 2019 10:43:29 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, master has been updated
via 8cc45af919dc56011dbf4c8965b9c1e4784e56d7 (commit)
from c15d2db3ce7ea49741d8792190f9212842db86ec (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=8cc45af919dc56011dbf4c8965b9c1e4784e56d7
commit 8cc45af919dc56011dbf4c8965b9c1e4784e56d7
Author: Andrew J. Schorr <address@hidden>
Date: Fri Aug 30 10:42:50 2019 -0400
In .developing mode, define MEMDEBUG to use malloc/free for block
allocation to facilitate finding memory leaks.
diff --git a/ChangeLog b/ChangeLog
index 5769a71..a64478c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2019-08-30 Andrew J. Schorr <address@hidden>
+ * configure.ac (.developing): Add -DMEMDEBUG to CFLAGS.
+ * awk.h (block_header): If MEMDEBUG is defined, add cnt field
+ to track the number of allocations.
+ (getblock, freeblock): When MEMDEBUG is defined, replace these
+ macros with calls to new functions r_getblock and r_freeblock.
+ * node.c (r_getblock, r_freeblock): New functions that simply
+ use malloc and free when MEMDEBUG is defined.
+
+2019-08-30 Andrew J. Schorr <address@hidden>
+
* interpret.h (r_interpret): For Op_match_rec, unref if a
dynamic regexp. Fixes another memory issue. See the thread starting
at https://lists.gnu.org/archive/html/bug-gawk/2019-08/msg00023.html.
diff --git a/awk.h b/awk.h
index 363e440..345d87b 100644
--- a/awk.h
+++ b/awk.h
@@ -1061,6 +1061,9 @@ struct block_item {
struct block_header {
struct block_item *freep;
size_t size;
+#ifdef MEMDEBUG
+ long cnt;
+#endif
};
enum block_id {
@@ -1323,12 +1326,23 @@ DEREF(NODE *r)
#define get_lhs(n, r) (n)->type == Node_var && ! var_uninitialized(n) ? \
&((n)->var_value) : r_get_lhs((n), (r))
+#ifdef MEMDEBUG
+
+extern void *r_getblock(int id);
+extern void r_freeblock(void *, int id);
+#define getblock(p, id, ty) (void) (p = r_getblock(id))
+#define freeblock(p, id) (void) (r_freeblock(p, id))
+
+#else /* MEMDEBUG */
+
#define getblock(p, id, ty) (void) ((p = (ty) nextfree[id].freep) ? \
(ty) (nextfree[id].freep = ((struct block_item *)
p)->freep) \
: (p = (ty) more_blocks(id)))
#define freeblock(p, id) (void) (((struct block_item *) p)->freep =
nextfree[id].freep, \
nextfree[id].freep = (struct block_item
*) p)
+#endif /* MEMDEBUG */
+
#define getnode(n) getblock(n, BLOCK_NODE, NODE *)
#define freenode(n) freeblock(n, BLOCK_NODE)
diff --git a/configure b/configure
index a9f5e7c..ee0bbbf 100755
--- a/configure
+++ b/configure
@@ -5409,7 +5409,7 @@ $as_echo_n "checking for special development options... "
>&6; }
if test -f $srcdir/.developing
then
# add other debug flags as appropriate, save GAWKDEBUG for emergencies
- CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG -DLOCALEDEBUG"
+ CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG -DLOCALEDEBUG -DMEMDEBUG"
# turn on compiler warnings if we're doing development
# enable debugging using macros also
diff --git a/configure.ac b/configure.ac
index 436ef4a..7c01f48 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,7 +111,7 @@ AC_MSG_CHECKING([for special development options])
if test -f $srcdir/.developing
then
# add other debug flags as appropriate, save GAWKDEBUG for emergencies
- CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG -DLOCALEDEBUG"
+ CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG -DLOCALEDEBUG -DMEMDEBUG"
# turn on compiler warnings if we're doing development
# enable debugging using macros also
diff --git a/node.c b/node.c
index 9574c3e..eacd17b 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
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 10 ++++++++++
awk.h | 14 ++++++++++++++
configure | 2 +-
configure.ac | 2 +-
node.c | 21 +++++++++++++++++++++
5 files changed, 47 insertions(+), 2 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-3818-g8cc45af,
Andrew J. Schorr <=