103 assert(size != NULL); |
103 assert(size != NULL); |
104 assert(src != NULL); |
104 assert(src != NULL); |
105 |
105 |
106 // determine capacity |
106 // determine capacity |
107 size_t cap = capacity == NULL ? *size : *capacity; |
107 size_t cap = capacity == NULL ? *size : *capacity; |
|
108 assert(*target != NULL || cap == 0); |
108 |
109 |
109 // check if resize is required |
110 // check if resize is required |
110 size_t minsize = index + elem_count; |
111 size_t minsize = index + elem_count; |
111 size_t newsize = *size < minsize ? minsize : *size; |
112 size_t newsize = *size < minsize ? minsize : *size; |
112 bool needrealloc = newsize > cap; |
113 bool needrealloc = newsize > cap; |