Skip to content

Commit c735396

Browse files
Dmitry S. Dolzhenkogitster
authored andcommitted
sha1_file.c: use ALLOC_GROW() in pretend_sha1_file()
Helped-by: He Sun <sunheehnus@gmail.com> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 999f566 commit c735396

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

sha1_file.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,12 +2626,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
26262626
hash_sha1_file(buf, len, typename(type), sha1);
26272627
if (has_sha1_file(sha1) || find_cached_object(sha1))
26282628
return 0;
2629-
if (cached_object_alloc <= cached_object_nr) {
2630-
cached_object_alloc = alloc_nr(cached_object_alloc);
2631-
cached_objects = xrealloc(cached_objects,
2632-
sizeof(*cached_objects) *
2633-
cached_object_alloc);
2634-
}
2629+
ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc);
26352630
co = &cached_objects[cached_object_nr++];
26362631
co->size = len;
26372632
co->type = type;

0 commit comments

Comments
 (0)