| 254 | } |
| 255 | |
| 256 | int acl_array_succ_insert(ACL_ARRAY *a, int position, void *obj) |
| 257 | { |
| 258 | int idx, position_succ; |
| 259 | |
| 260 | /* |
| 261 | * a->items[count - 1] should be the last valid item node |
| 262 | * position should: position >= 0 && position <= a->count - 1 |
| 263 | */ |
| 264 | if (position < 0 || position >= a->count) |
| 265 | return -1; |
| 266 | |
| 267 | if (a->count >= a->capacity) |
| 268 | acl_array_grow(a, a->count + 1); |
| 269 | |
| 270 | position_succ = position + 1; |
| 271 | |
| 272 | /* |
| 273 | * position_succ should: |
| 274 | * position_succ > 0 (position >= 0 and position_succ = position + 1) |
| 275 | * and position_succ <= a->count (when position == a->count - 1, |
| 276 | * position == a->count, and just append one new node after the |
| 277 | * last node) |
| 278 | * NOTICE: the C's index begin with 0 |
| 279 | */ |
| 280 | for (idx = a->count; idx > position_succ; idx--) |
| 281 | a->items[idx] = a->items[idx - 1]; |
| 282 | a->items[position_succ] = obj; |
| 283 | a->count++; |
| 284 | return position_succ; |
| 285 | } |
| 286 | |
| 287 | int acl_array_prepend(ACL_ARRAY *a, void *obj) |
| 288 | { |
no test coverage detected
searching dependent graphs…