[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, feature/assoc_set, created. gawk-4.1.0-3
From: |
Andrew J. Schorr |
Subject: |
[gawk-diffs] [SCM] gawk branch, feature/assoc_set, created. gawk-4.1.0-3598-g69b4c6e |
Date: |
Mon, 14 Jan 2019 22:39:58 -0500 (EST) |
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, feature/assoc_set has been created
at 69b4c6e0b70f92e829848e21c4d8983fac904f30 (commit)
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=69b4c6e0b70f92e829848e21c4d8983fac904f30
commit 69b4c6e0b70f92e829848e21c4d8983fac904f30
Author: Andrew J. Schorr <address@hidden>
Date: Mon Jan 14 22:39:00 2019 -0500
Add assoc_set inline function for setting array elements.
diff --git a/ChangeLog b/ChangeLog
index da93370..f90a00f 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2019-01-14 Andrew J. Schorr <address@hidden>
+ * awk.h (assoc_set): Add new inline function to set an array element
+ to eliminate code duplication and reduce the chance of memory leaks.
+
+2019-01-14 Andrew J. Schorr <address@hidden>
+
* builtin.c (do_typeof): Fix memory leak when populating the
optional array, and make sure to call the astore method.
diff --git a/awk.h b/awk.h
index bac788b..9b5d359 100644
--- a/awk.h
+++ b/awk.h
@@ -1362,6 +1362,21 @@ extern int fatal_tag_valid;
/* assoc_remove --- remove an index from symbol[] */
#define assoc_remove(a, s) ((a)->aremove(a, s) != NULL)
+/* assoc_set -- set an element in an array */
+
+static inline void
+assoc_set(NODE *array, NODE *sub, NODE *value)
+{
+
+ NODE **lhs = assoc_lookup(array, sub);
+ unref(*lhs);
+ *lhs = value;
+ if (array->astore != NULL)
+ (*array->astore)(array, sub);
+ unref(sub);
+}
+
+
/* ------------- Function prototypes or defs (as appropriate) ------------- */
/* array.c */
typedef enum { SORTED_IN = 1, ASORT, ASORTI } sort_context_t;
-----------------------------------------------------------------------
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, feature/assoc_set, created. gawk-4.1.0-3598-g69b4c6e,
Andrew J. Schorr <=