MCPcopy Create free account
hub / github.com/git/git / reftable_alloc_grow

Function reftable_alloc_grow

reftable/basics.h:218–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216 } while (0)
217
218static inline void *reftable_alloc_grow(void *p, size_t nelem, size_t elsize,
219 size_t *allocp)
220{
221 void *new_p;
222 size_t alloc = *allocp * 2 + 1, alloc_bytes;
223 if (alloc < nelem)
224 alloc = nelem;
225 if (reftable_alloc_size(elsize, alloc, &alloc_bytes) < 0) {
226 errno = ENOMEM;
227 return p;
228 }
229 new_p = reftable_realloc(p, alloc_bytes);
230 if (!new_p)
231 return p;
232 *allocp = alloc;
233 return new_p;
234}
235
236#define REFTABLE_ALLOC_GROW(x, nr, alloc) ( \
237 (nr) > (alloc) && ( \

Callers

nothing calls this directly

Calls 2

reftable_alloc_sizeFunction · 0.85
reftable_reallocFunction · 0.85

Tested by

no test coverage detected