read-cache.c: use ALLOC_GROW() in add_index_entry()
authorDmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>
Mon, 3 Mar 2014 22:32:01 +0000 (02:32 +0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Mar 2014 22:54:54 +0000 (14:54 -0800)
Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c
index 33dd676ccbbd24e0bace49347f1f5d81b5099bcc..40dbec92ac7df06eb706075f750b346b656b1753 100644 (file)
@@ -993,11 +993,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti
        }
 
        /* Make sure the array is big enough .. */
-       if (istate->cache_nr == istate->cache_alloc) {
-               istate->cache_alloc = alloc_nr(istate->cache_alloc);
-               istate->cache = xrealloc(istate->cache,
-                                       istate->cache_alloc * sizeof(*istate->cache));
-       }
+       ALLOC_GROW(istate->cache, istate->cache_nr + 1, istate->cache_alloc);
 
        /* Add it in.. */
        istate->cache_nr++;