Added array_list_del_idx and json_object_array_del_idx

This commit is contained in:
Mark Swoope
2015-04-02 14:05:27 -07:00
parent 68d856f618
commit cdca9d3c8e
4 changed files with 34 additions and 0 deletions

View File

@@ -106,3 +106,18 @@ array_list_length(struct array_list *arr)
{
return arr->length;
}
int
array_list_del_idx( struct array_list *arr, int idx, int count )
{
int i, stop;
stop = idx + count;
if ( idx >= arr->length || stop > arr->length ) return -1;
for ( i = idx; i < stop; ++i ) {
if ( arr->array[i] ) arr->free_fn( arr->array[i] );
}
memmove( arr->array + idx, arr->array + stop, (arr->length - stop) * sizeof(void*) );
arr->length -= count;
return 0;
}