summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dynarr.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/dynarr.h b/dynarr.h
index 321325b..c9ce637 100644
--- a/dynarr.h
+++ b/dynarr.h
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdint.h>
+#include <string.h>
#include <err.h>
typedef struct { size_t count, capacity; } DynArrHeader;
@@ -35,6 +36,12 @@ typedef struct { size_t count, capacity; } DynArrHeader;
(da)[DA_HEADER(da)->count++] = item;\
}
+#define DA_PUSH_MULT(da, buf, n) {\
+ DA_FIT(da, DA_LEN(da) + n);\
+ memcpy(&(da)[DA_HEADER(da)->count], buf, n * sizeof(*(da)));\
+ DA_HEADER(da)->count += n;\
+}
+
#define DA_FOR(da, type, name)\
for (type *name = (da); name < &(da)[DA_LEN(da)]; name++)