aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2012-05-13 16:39:35 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2012-05-13 16:39:35 -0400
commit06323619397520aba2fc2f8f983d67d06c6610fa (patch)
tree491b6c4342a1ba34fa853d129ca89d672efe4da6
parent3d662631342d999b3c80952f2e8eca8b390bdd95 (diff)
downloadegawk-06323619397520aba2fc2f8f983d67d06c6610fa.tar.gz
egawk-06323619397520aba2fc2f8f983d67d06c6610fa.tar.bz2
egawk-06323619397520aba2fc2f8f983d67d06c6610fa.zip
Add comment to extension/filefuncs.c discussing unref on value from assoc_lookup.
-rw-r--r--TODO.xgawk2
-rw-r--r--extension/ChangeLog5
-rw-r--r--extension/filefuncs.c7
3 files changed, 12 insertions, 2 deletions
diff --git a/TODO.xgawk b/TODO.xgawk
index cf676c15..1917c73d 100644
--- a/TODO.xgawk
+++ b/TODO.xgawk
@@ -36,8 +36,6 @@ To do (not necessarily in this order):
- The -f flag should not eliminate duplicates.
-- Add comment about using unref on value returned from assoc_lookup.
-
- Enable default ".awk" search in io.c:find_source(). The simple change
is to add this code inline in io.c:
#ifndef DEFAULT_FILETYPE
diff --git a/extension/ChangeLog b/extension/ChangeLog
index df493227..a3526863 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,5 +1,10 @@
2012-05-13 Andrew J. Schorr <aschorr@telemetry-investments.com>
+ * filefuncs.c (array_set): Add a comment discussing the use of unref
+ on the value returned by assoc_lookup.
+
+2012-05-13 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
* xreadlink.[ch]: Remove unused files.
2012-05-11 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 9758ba8e..01f3fce2 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -220,6 +220,13 @@ array_set(NODE *array, const char *sub, NODE *value)
tmp = make_string(sub, strlen(sub));
aptr = assoc_lookup(array, tmp);
unref(tmp);
+ /*
+ * Note: since we initialized with assoc_clear, we know that aptr
+ * has been initialized with Nnull_string. Thus, the call to
+ * unref(*aptr) is not strictly necessary. However, I think it is
+ * generally more correct to call unref to maintain the proper
+ * reference count.
+ */
unref(*aptr);
*aptr = value;
}