| 225 | } |
| 226 | |
| 227 | int acl_array_pred_insert(ACL_ARRAY *a, int position, void *obj) |
| 228 | { |
| 229 | int idx; |
| 230 | |
| 231 | /* |
| 232 | * a->items[count - 1] should be the last valid item node |
| 233 | * position should: positioin >= 0 && position <= a->count - 1 |
| 234 | */ |
| 235 | if(position < 0 || position >= a->count) |
| 236 | return -1; |
| 237 | |
| 238 | if(a->count >= a->capacity) |
| 239 | acl_array_grow(a, a->count + 1); |
| 240 | |
| 241 | /* NOTICE: the C's index begin with 0 |
| 242 | * when position == 0, just prepend one new node before the first node |
| 243 | * of the array |
| 244 | */ |
| 245 | for(idx = a->count; idx > position && idx > 0; idx--) { |
| 246 | /* if idx == 0 then we has arrived |
| 247 | * at the beginning of the array |
| 248 | */ |
| 249 | a->items[idx] = a->items[idx - 1]; |
| 250 | } |
| 251 | a->items[position] = obj; |
| 252 | a->count++; |
| 253 | return position; |
| 254 | } |
| 255 | |
| 256 | int acl_array_succ_insert(ACL_ARRAY *a, int position, void *obj) |
| 257 | { |
no test coverage detected
searching dependent graphs…