| 73 | /* grows internal buffer to satisfy required minimal capacity */ |
| 74 | |
| 75 | void 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 | |
| 102 | static void array_init(ACL_ARRAY *a) |
| 103 | { |
no test coverage detected
searching dependent graphs…