[ccan] darray_remove
Andy Grover
agrover at redhat.com
Thu Jul 24 05:11:04 EST 2014
I was very happy to find darray, but did also need to remove elements
from the array besides ones at the end. Of course the performance will
be bad but that's expected. Here it is:
#define darray_remove(arr, i) do { \
if (i < arr.size-1) \
memmove(&(arr).item[i], &(arr).item[i+1],
((arr).size-1-i)*sizeof(*(arr).item)); \
(arr).size--; \
} while (0)
It also might be nice to realloc down if size < alloc/2, but this
doesn't do that.
Regards -- Andy
More information about the ccan
mailing list