From 56c4cdf36938c714968a616afe98809902b83fc8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 1 Jun 2015 01:35:56 +0200 Subject: ta: add another array helper macro Stupid C. --- ta/ta_talloc.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ta') 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 { \ -- cgit v1.2.3