| 374 | } |
| 375 | |
| 376 | int 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 |
no test coverage detected
searching dependent graphs…