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

Function acl_array_succ_insert

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

Source from the content-addressed store, hash-verified

254}
255
256int 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
287int acl_array_prepend(ACL_ARRAY *a, void *obj)
288{

Callers 1

dlink_succ_insertFunction · 0.85

Calls 1

acl_array_growFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…