From 23b4b58d57c7f9f01144a5e59daf26fbe6d5ba4d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 8 Sep 2016 10:47:33 -0400 Subject: [PATCH] delta: Unreference files we've processed This should help avoid address space exhaustion on 32 bit systems, and in general is obviously going to improve efficiency. Closes: #498 Approved by: alexlarsson --- .../ostree-repo-static-delta-compilation.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c index 15b1df8d..acface61 100644 --- a/src/libostree/ostree-repo-static-delta-compilation.c +++ b/src/libostree/ostree-repo-static-delta-compilation.c @@ -429,8 +429,8 @@ content_rollsums_free (ContentRollsum *rollsum) { g_free (rollsum->from_checksum); _ostree_rollsum_matches_free (rollsum->matches); - g_bytes_unref (rollsum->tmp_from); - g_bytes_unref (rollsum->tmp_to); + g_clear_pointer (&rollsum->tmp_from, g_bytes_unref); + g_clear_pointer (&rollsum->tmp_to, g_bytes_unref); g_free (rollsum); } @@ -438,8 +438,8 @@ static void content_bsdiffs_free (ContentBsdiff *bsdiff) { g_free (bsdiff->from_checksum); - g_bytes_unref (bsdiff->tmp_from); - g_bytes_unref (bsdiff->tmp_to); + g_clear_pointer (&bsdiff->tmp_from, g_bytes_unref); + g_clear_pointer (&bsdiff->tmp_to, g_bytes_unref); g_free (bsdiff); } @@ -758,6 +758,9 @@ process_one_rollsum (OstreeRepo *repo, g_string_append_c (current_part->operations, (gchar)OSTREE_STATIC_DELTA_OP_CLOSE); } + g_clear_pointer (&rollsum->tmp_from, g_bytes_unref); + g_clear_pointer (&rollsum->tmp_to, g_bytes_unref); + ret = TRUE; out: return ret; @@ -854,6 +857,9 @@ process_one_bsdiff (OstreeRepo *repo, g_string_append_c (current_part->operations, (gchar)OSTREE_STATIC_DELTA_OP_UNSET_READ_SOURCE); + g_clear_pointer (&bsdiff_content->tmp_from, g_bytes_unref); + g_clear_pointer (&bsdiff_content->tmp_to, g_bytes_unref); + ret = TRUE; out: return ret;