]> git.ozlabs.org Git - ccan/commit
darray: Fix bug in the darray_remove() macro
authorDamien Grassart <damien@grassart.com>
Tue, 29 Aug 2017 10:08:42 +0000 (12:08 +0200)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 29 Aug 2017 11:05:07 +0000 (21:05 +1000)
commitdf8c663a04bb10c3af0b56404ea0f57445e7f656
treea44a2a4a6c2e5fc34ed38293908e54dc2e49e712
parentd4779b16fdd44a1a4ccf3c82ecd5af71ba096289
darray: Fix bug in the darray_remove() macro

The memmove() call should be using the index argument to determine the
number of bytes to copy. To be consistent with the rest of the code,
we should also not evaluate the index parameter multiple
times. Calling this with rand() % arr.size would otherwise generally
segfault.

Finally, we want to avoid using "index" as an identifier so as to not
shadow index(3) in the C library.

Signed-off-by: Damien Grassart <damien@grassart.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/darray/darray.h