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

Function private_array_grow

lib_acl/src/private/private_array.c:75–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73/* grows internal buffer to satisfy required minimal capacity */
74
75void private_array_grow(ACL_ARRAY *a, int min_capacity)
76{
77 int min_delta = 16;
78 int delta;
79
80 /* don't need to grow the capacity of the array */
81 if(a->capacity >= min_capacity)
82 return;
83 delta = min_capacity;
84 /* make delta a multiple of min_delta */
85 delta += min_delta - 1;
86 delta /= min_delta;
87 delta *= min_delta;
88 /* actual grow */
89 if (delta <= 0)
90 return;
91 a->capacity += delta;
92 if (a->items) {
93 a->items = (void **) realloc(a->items, a->capacity * sizeof(void *));
94 } else {
95 a->items = (void **) malloc(a->capacity * sizeof(void *));
96 }
97
98 /* reset, just in case */
99 memset(a->items + a->count, 0, (a->capacity - a->count) * sizeof(void *));
100}
101
102static void array_init(ACL_ARRAY *a)
103{

Callers 2

array_prepare_appendFunction · 0.85
private_array_pushFunction · 0.85

Calls 2

reallocFunction · 0.85
mallocFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…