]> git.ipfire.org Git - thirdparty/git.git/commit - git-compat-util.h
add MOVE_ARRAY
authorRené Scharfe <l.s.r@web.de>
Sat, 15 Jul 2017 19:36:20 +0000 (21:36 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Jul 2017 21:54:53 +0000 (14:54 -0700)
commit578398071e45d296c3dc1de10acdbc15365e763f
treed49c040e24d00c7d1c706e4146e4de2bdae1fa5f
parentf3da2b79be9565779e4f76dc5812c68e156afdf0
add MOVE_ARRAY

Similar to COPY_ARRAY (introduced in 60566cbb58), add a safe and
convenient helper for moving potentially overlapping ranges of array
entries.  It infers the element size, multiplies automatically and
safely to get the size in bytes, does a basic type safety check by
comparing element sizes and unlike memmove(3) it supports NULL
pointers iff 0 elements are to be moved.

Also add a semantic patch to demonstrate the helper's intended usage.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/coccinelle/array.cocci
git-compat-util.h