X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=cache.h;h=ed83d92c5a2735b2b7f8a7fc06276acbf0df8b18;hb=7051c3b1294a110a862a7b48e983490fba32389f;hp=cec19ba4489f858a0dd7f6701c2411ab6d29b938;hpb=ad2a2f6f0b40ba7c3dea8ec8ddcbc3f65f083998;p=git.git diff --git a/cache.h b/cache.h index cec19ba44..ed83d92c5 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)