aboutsummaryrefslogtreecommitdiffstats
path: root/awk.h
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2019-01-20 22:20:47 +0200
committerArnold D. Robbins <arnold@skeeve.com>2019-01-20 22:20:47 +0200
commit9a0812e1b5ed67c3e75e70749a7e2a54f9c2bfcc (patch)
treef7924aeb58a0b721e91f1127c92e18b3fbf3e54e /awk.h
parenta6ece4a82072150e4b269b5698bb8caf14075bcb (diff)
parent5766636f7bb7eb6d8fa9fd1b097ca74329062173 (diff)
downloadegawk-9a0812e1b5ed67c3e75e70749a7e2a54f9c2bfcc.tar.gz
egawk-9a0812e1b5ed67c3e75e70749a7e2a54f9c2bfcc.tar.bz2
egawk-9a0812e1b5ed67c3e75e70749a7e2a54f9c2bfcc.zip
Merge branch 'master' into feature/fix-ns-memleak
Diffstat (limited to 'awk.h')
-rw-r--r--awk.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/awk.h b/awk.h
index a18cf522..3ba5f1fc 100644
--- a/awk.h
+++ b/awk.h
@@ -1362,6 +1362,7 @@ extern int fatal_tag_valid;
/* assoc_remove --- remove an index from symbol[] */
#define assoc_remove(a, s) ((a)->aremove(a, s) != NULL)
+
/* ------------- Function prototypes or defs (as appropriate) ------------- */
/* array.c */
typedef enum { SORTED_IN = 1, ASORT, ASORTI } sort_context_t;
@@ -2024,6 +2025,20 @@ make_number_node(unsigned int flags)
return r;
}
+/* assoc_set -- set an element in an array. Does unref(sub)! */
+
+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);
+}
+
/*
* str_terminate_f, str_terminate, str_restore: function and macros to
* reduce chances of typos when terminating and restoring strings.