]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-compat-util.h
add DUP_ARRAY
[thirdparty/git.git] / git-compat-util.h
index e81bb14fc90622ad44f2c31a3a69f8e425c75514..44abb240ae48aa29a5498738548b5d692b3008e0 100644 (file)
@@ -1115,6 +1115,11 @@ static inline void move_array(void *dst, const void *src, size_t n, size_t size)
                memmove(dst, src, st_mult(size, n));
 }
 
+#define DUP_ARRAY(dst, src, n) do { \
+       size_t dup_array_n_ = (n); \
+       COPY_ARRAY(ALLOC_ARRAY((dst), dup_array_n_), (src), dup_array_n_); \
+} while (0)
+
 /*
  * These functions help you allocate structs with flex arrays, and copy
  * the data directly into the array. For example, if you had: