int sampgdk_array_find_remove(struct sampgdk_array *a, const void *key, sampgdk_array_cmp cmp) { int index; void *cur; assert(a != NULL); assert(cmp != NULL); for (index = 0; index < a->count; index++) { cur = sampgdk_array_get(a, index); if (cmp(key, cur) == 0) { sampgdk_array_remove(a, index, 1); return index; } } return -EINVAL; }
int sampgdk_array_remove_single(struct sampgdk_array *a, int index) { assert(a != NULL); assert(index >= 0); assert(index < a->count); return sampgdk_array_remove(a, index, 1); }
int sampgdk_array_clear(struct sampgdk_array *a) { return sampgdk_array_remove(a, 0, a->count); }