MCPcopy Create free account
hub / github.com/acl-dev/acl / acl_array_mv_idx

Function acl_array_mv_idx

lib_acl/src/stdlib/common/acl_array.c:376–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374}
375
376int acl_array_mv_idx(ACL_ARRAY *a, int ito, int ifrom, void (*free_fn)(void *))
377{
378 int i, i_obj, i_src, i_max;
379
380 if (ito < 0 || ifrom < 0 || a->count < 0)
381 return -1;
382
383 if (a->count == 0 || ito >= ifrom || ifrom >= a->count)
384 return 0;
385
386 i_obj = ito;
387 i_src = ifrom;
388 i_max = a->count - 1;
389
390 if (free_fn != NULL) {
391 for (i = i_obj; i < i_src; i++) {
392 if (a->items[i] != NULL)
393 free_fn(a->items[i]);
394 a->items[i] = NULL;
395 }
396 }
397 for (; i_src <= i_max; i_src++) {
398 a->items[i_obj] = a->items[i_src];
399 i_obj++;
400 }
401
402 a->count -= ifrom - ito;
403 if (a->count < 0) /* imposible, sanity check */
404 return -1;
405
406 return 0;
407}
408
409/* if you are going to append a known and large number of items,
410 * call this first

Callers 1

dlink_node_mergeFunction · 0.85

Calls 1

free_fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…