Merge branch 'rs/move-array' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 23 Aug 2017 21:33:46 +0000 (14:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Aug 2017 21:33:46 +0000 (14:33 -0700)
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

1  2 
git-compat-util.h
diff --combined git-compat-util.h
index db9c22de7693af4e905fdeb0a1766ba4469eda94,159f82154a8a4d24433d0767e83413d8e1dd105b..7d2c0ca75922ea1ca8c67ec798ff8ce1249c925f
  #include <sys/sysctl.h>
  #endif
  
 +#if defined(__CYGWIN__)
 +#include "compat/cygwin.h"
 +#endif
  #if defined(__MINGW32__)
  /* pull in Windows compatibility stuff */
  #include "compat/mingw.h"
@@@ -828,6 -825,14 +828,14 @@@ static inline void copy_array(void *dst
                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: