Skip to content

Commit 51124a5

Browse files
authored
Merge pull request libgit2#5170 from bk2204/packbuilder-efficient-realloc
Allocate memory more efficiently when packing objects
2 parents f92d495 + c4df926 commit 51124a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
223223

224224
if (pb->nr_objects >= pb->nr_alloc) {
225225
GIT_ERROR_CHECK_ALLOC_ADD(&newsize, pb->nr_alloc, 1024);
226-
GIT_ERROR_CHECK_ALLOC_MULTIPLY(&newsize, newsize, 3 / 2);
226+
GIT_ERROR_CHECK_ALLOC_MULTIPLY(&newsize, newsize / 2, 3);
227227

228228
if (!git__is_uint32(newsize)) {
229229
git_error_set(GIT_ERROR_NOMEMORY, "packfile too large to fit in memory.");

0 commit comments

Comments
 (0)