[ccan] darray_remove

Rusty Russell rusty at rustcorp.com.au
Tue Aug 5 15:43:34 EST 2014


Andy Grover <agrover at redhat.com> writes:
> 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.

Hmm, unfortunately Joey seems to be MIA.  There are a couple of patches
for this module.

Would you like to become darray maintainer?  It's pretty simple: give me
your ssh key and I'll give you commit access :)

Cheers,
Rusty.
PS.  I pinged Joey on StackOverflow, let's see...


More information about the ccan mailing list