diff options
Diffstat (limited to 'node.c')
-rw-r--r-- | node.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -27,11 +27,11 @@ #include "awk.h" #include "floatmagic.h" /* definition of isnan */ -static NODE *r_make_number(double x); +static NODE *r_make_number(double x, const char *file, int line, const char *func); static AWKNUM get_ieee_magic_val(char *val); extern NODE **fmt_list; /* declared in eval.c */ -NODE *(*make_number)(double) = r_make_number; +NODE *(*make_number)(double, const char *, int, const char *) = r_make_number; NODE *(*str2number)(NODE *) = r_force_number; NODE *(*format_val)(const char *, int, NODE *) = r_format_val; int (*cmp_numbers)(const NODE *, const NODE *) = cmp_awknums; @@ -357,10 +357,13 @@ r_dupnode(NODE *n) /* r_make_number --- allocate a node with defined number */ static NODE * -r_make_number(double x) +r_make_number(double x, const char *file, int line, const char *func) { NODE *r = make_number_node(0); r->numbr = x; + if (watched && r == watched) + fprintf(stderr, "%s:%d:%s: clobbering %#p with %g\n", + file, line, func, watched, x); return r; } @@ -397,7 +400,9 @@ NODE * make_str_node(const char *s, size_t len, int flags) { NODE *r; + getnode(r); + memset(r, '\0', sizeof(*r)); r->type = Node_val; r->numbr = 0; r->flags = (MALLOC|STRING|STRCUR); @@ -498,8 +503,13 @@ make_typed_regex(const char *re, size_t len) /* unref --- remove reference to a particular node */ void -r_unref(NODE *tmp) +r_unref(NODE *tmp, const char *file, int line, const char *func) { + extern NODE *watched; + + if (tmp == watched) + fprintf(stderr, "r_unref, invoked from %s:%d:%s\n", file, line, func); + #ifdef GAWKDEBUG /* Do the same as in awk.h:unref(). */ assert(tmp == NULL || tmp->valref > 0); |