[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, array-iface, created. 07e08a881ae177d3e3
From: |
John Haque |
Subject: |
[gawk-diffs] [SCM] gawk branch, array-iface, created. 07e08a881ae177d3e3b7cfd2c5199443c6db3dd0 |
Date: |
Tue, 17 Apr 2012 18:55:24 +0000 |
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, array-iface has been created
at 07e08a881ae177d3e3b7cfd2c5199443c6db3dd0 (commit)
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=07e08a881ae177d3e3b7cfd2c5199443c6db3dd0
commit 07e08a881ae177d3e3b7cfd2c5199443c6db3dd0
Author: john haque <address@hidden>
Date: Tue Apr 17 13:29:32 2012 -0500
Use unref when freeing a null array element.
diff --git a/array.c b/array.c
index c8e230f..a0c74e9 100644
--- a/array.c
+++ b/array.c
@@ -798,7 +798,7 @@ asort_actual(int nargs, SORT_CTXT ctxt)
{
NODE *array, *dest = NULL, *result;
NODE *r, *subs, *s;
- NODE **list = NULL, **ptr;
+ NODE **list = NULL, **ptr, **lhs;
unsigned long num_elems, i;
const char *sort_str;
@@ -880,7 +880,9 @@ asort_actual(int nargs, SORT_CTXT ctxt)
for (i = 1, ptr = list; i <= num_elems; i++, ptr += 2) {
subs = make_number(i);
- *assoc_lookup(result, subs) = *ptr;
+ lhs = assoc_lookup(result, subs);
+ unref(*lhs);
+ *lhs = *ptr;
unref(subs);
}
} else {
@@ -896,9 +898,11 @@ asort_actual(int nargs, SORT_CTXT ctxt)
/* value node */
r = *ptr++;
- if (r->type == Node_val)
- *assoc_lookup(result, subs) = dupnode(r);
- else {
+ if (r->type == Node_val) {
+ lhs = assoc_lookup(result, subs);
+ unref(*lhs);
+ *lhs = dupnode(r);
+ } else {
NODE *arr;
arr = make_array();
subs = force_string(subs);
@@ -906,7 +910,9 @@ asort_actual(int nargs, SORT_CTXT ctxt)
subs->stptr = NULL;
subs->flags &= ~STRCUR;
arr->parent_array = array; /* actual parent,
not the temporary one. */
- *assoc_lookup(result, subs) = assoc_copy(r,
arr);
+ lhs = assoc_lookup(result, subs);
+ unref(*lhs);
+ *lhs = assoc_copy(r, arr);
}
unref(subs);
}
diff --git a/interpret.h b/interpret.h
index 009e6e1..83b908c 100644
--- a/interpret.h
+++ b/interpret.h
@@ -224,7 +224,9 @@ top:
if (r == NULL) {
r = make_array();
r->parent_array = t1;
- *assoc_lookup(t1, t2) = r;
+ lhs = assoc_lookup(t1, t2);
+ unref(*lhs);
+ *lhs = r;
t2 = force_string(t2);
r->vname = estrdup(t2->stptr, t2->stlen);
/* the subscript in parent array */
} else if (r->type != Node_var_array) {
-----------------------------------------------------------------------
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, array-iface, created. 07e08a881ae177d3e3b7cfd2c5199443c6db3dd0,
John Haque <=