summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/cache.h b/cache.h
index cec19ba..ed83d92 100644
--- a/cache.h
+++ b/cache.h
@@ -234,8 +234,11 @@ extern void verify_non_filename(const char *prefix, const char *name);
*/
#define ALLOC_GROW(x, nr, alloc) \
do { \
- if ((nr) >= alloc) { \
- alloc = alloc_nr(alloc); \
+ if ((nr) > alloc) { \
+ if (alloc_nr(alloc) < (nr)) \
+ alloc = (nr); \
+ else \
+ alloc = alloc_nr(alloc); \
x = xrealloc((x), alloc * sizeof(*(x))); \
} \
} while(0)