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

Function acl_array_pred_insert

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

Source from the content-addressed store, hash-verified

225}
226
227int 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
256int acl_array_succ_insert(ACL_ARRAY *a, int position, void *obj)
257{

Callers 2

dlink_pred_insertFunction · 0.85
acl_array_prependFunction · 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…