From: Dmitry S. Dolzhenko Date: Mon, 3 Mar 2014 22:32:02 +0000 (+0400) Subject: sha1_file.c: use ALLOC_GROW() in pretend_sha1_file() X-Git-Tag: v2.0.0-rc0~97^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c7353967ca8ede681e9f8fbac98a650450631990 sha1_file.c: use ALLOC_GROW() in pretend_sha1_file() Helped-by: He Sun Signed-off-by: Dmitry S. Dolzhenko Signed-off-by: Junio C Hamano --- diff --git a/sha1_file.c b/sha1_file.c index 6e8c05d108..2af06f8423 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2626,12 +2626,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type, hash_sha1_file(buf, len, typename(type), sha1); if (has_sha1_file(sha1) || find_cached_object(sha1)) return 0; - if (cached_object_alloc <= cached_object_nr) { - cached_object_alloc = alloc_nr(cached_object_alloc); - cached_objects = xrealloc(cached_objects, - sizeof(*cached_objects) * - cached_object_alloc); - } + ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc); co = &cached_objects[cached_object_nr++]; co->size = len; co->type = type;