diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-08-23 23:33:46 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-08-23 23:33:46 +0200 |
commit | d3b7ee087e3ed409b943d62501bd7fb8dbd96dd8 (patch) | |
tree | 1ed0f2f407610d50b984a4fa9b95bb72eaa17c14 /git-compat-util.h | |
parent | Merge branch 'rs/bswap-ubsan-fix' into maint (diff) | |
parent | ls-files: don't try to prune an empty index (diff) | |
download | git-d3b7ee087e3ed409b943d62501bd7fb8dbd96dd8.tar.xz git-d3b7ee087e3ed409b943d62501bd7fb8dbd96dd8.zip |
Merge branch 'rs/move-array' into maint
Code clean-up.
* rs/move-array:
ls-files: don't try to prune an empty index
apply: use COPY_ARRAY and MOVE_ARRAY in update_image()
use MOVE_ARRAY
add MOVE_ARRAY
Diffstat (limited to 'git-compat-util.h')
-rw-r--r-- | git-compat-util.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index db9c22de76..7d2c0ca759 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -828,6 +828,14 @@ static inline void copy_array(void *dst, const void *src, size_t n, size_t size) memcpy(dst, src, st_mult(size, n)); } +#define MOVE_ARRAY(dst, src, n) move_array((dst), (src), (n), sizeof(*(dst)) + \ + BUILD_ASSERT_OR_ZERO(sizeof(*(dst)) == sizeof(*(src)))) +static inline void move_array(void *dst, const void *src, size_t n, size_t size) +{ + if (n) + memmove(dst, src, st_mult(size, n)); +} + /* * These functions help you allocate structs with flex arrays, and copy * the data directly into the array. For example, if you had: |