summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorDmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>2014-03-04 02:32:02 +0400
committerJunio C Hamano <gitster@pobox.com>2014-03-03 14:54:58 -0800
commitc7353967ca8ede681e9f8fbac98a650450631990 (patch)
tree85646725d4da9125224dc13d5b3e08db2e37df66 /sha1_file.c
parent999f566013cf4102c07b0cdbffba419eadc7b368 (diff)
downloadgit-c7353967ca8ede681e9f8fbac98a650450631990.tar.gz
sha1_file.c: use ALLOC_GROW() in pretend_sha1_file()dd/use-alloc-grow
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c7
1 files changed, 1 insertions, 6 deletions
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;