[ccan] [PATCH 1/2] darray: Fix bug in the darray_remove() macro
Damien Grassart
damien at grassart.com
Sun Aug 27 02:26:20 AEST 2017
The memmove() call should be using the index argument to determine the
number of bytes to copy.
Signed-off-by: Damien Grassart <damien at grassart.com>
---
ccan/darray/darray.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ccan/darray/darray.h b/ccan/darray/darray.h
index 75112419..8d47645b 100644
--- a/ccan/darray/darray.h
+++ b/ccan/darray/darray.h
@@ -225,7 +225,7 @@ typedef darray(unsigned long) darray_ulong;
/* Warning, slow: Requires copying all elements after removed item. */
#define darray_remove(arr, index) do { \
if (index < arr.size-1) \
- memmove(&(arr).item[index], &(arr).item[index+1], ((arr).size-1-i)*sizeof(*(arr).item)); \
+ memmove(&(arr).item[index], &(arr).item[index+1], ((arr).size-1-index)*sizeof(*(arr).item)); \
(arr).size--; \
} while(0)
--
2.14.1
More information about the ccan
mailing list