aboutsummaryrefslogtreecommitdiffhomepage
path: root/ta
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-06-01 01:35:56 +0200
committerGravatar wm4 <wm4@nowhere>2015-06-01 01:35:56 +0200
commit56c4cdf36938c714968a616afe98809902b83fc8 (patch)
tree1c28e1378d0b924877765c64786ef71637c05b05 /ta
parentebde784fabe12791956cbe4a23a9e4bda4a4a205 (diff)
ta: add another array helper macro
Stupid C.
Diffstat (limited to 'ta')
-rw-r--r--ta/ta_talloc.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/ta/ta_talloc.h b/ta/ta_talloc.h
index 1cf99236f4..2331b4e08e 100644
--- a/ta/ta_talloc.h
+++ b/ta/ta_talloc.h
@@ -99,6 +99,17 @@ char *ta_talloc_asprintf_append_buffer(char *s, const char *fmt, ...) TA_PRF(2,
(idxvar)++; \
} while (0)
+#define MP_TARRAY_INSERT_AT(ctx, p, idxvar, at, ...)\
+ do { \
+ size_t at_ = (at); \
+ assert(at_ <= (idxvar)); \
+ MP_TARRAY_GROW(ctx, p, idxvar); \
+ memmove((p) + at_ + 1, (p) + at_, \
+ ((idxvar) - at_) * sizeof((p)[0])); \
+ (idxvar)++; \
+ (p)[at_] = (TA_EXPAND_ARGS(__VA_ARGS__)); \
+ } while (0)
+
// Doesn't actually free any memory, or do any other talloc calls.
#define MP_TARRAY_REMOVE_AT(p, idxvar, at) \
do { \