]>
git.proxmox.com Git - libgit2.git/blob - src/util.h
1 #ifndef INCLUDE_util_h__
2 #define INCLUDE_util_h__
4 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
7 * Realloc the buffer pointed at by variable 'x' so that it can hold
8 * at least 'nr' entries; the number of entries currently allocated
9 * is 'alloc', using the standard growing factor alloc_nr() macro.
11 * DO NOT USE any expression with side-effect for 'x' or 'alloc'.
13 #define alloc_nr(x) (((x)+16)*3/2)
14 #define ALLOC_GROW(x, nr, alloc) \
17 if (alloc_nr(alloc) < (nr)) \
20 alloc = alloc_nr(alloc); \
21 x = xrealloc((x), alloc * sizeof(*(x))); \
25 #endif /* INCLUDE_util_h__ */