mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <>
Cc: Stefan Beller <>
Subject: [PATCH 2/3] xdiff/xhistogram: factor out memory cleanup into free_index()
Date: Thu, 19 Jul 2018 11:56:19 -0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

This will be useful in the next patch as we'll introduce multiple

Signed-off-by: Stefan Beller <>
 xdiff/xhistogram.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
index 6e20f75fe85..5098b6c5021 100644
--- a/xdiff/xhistogram.c
+++ b/xdiff/xhistogram.c
@@ -243,6 +243,14 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
 				  line1, count1, line2, count2);
+static inline void free_index(struct histindex *index)
+	xdl_free(index->records);
+	xdl_free(index->line_map);
+	xdl_free(index->next_ptrs);
+	xdl_cha_free(&index->rcha);
 static int find_lcs(struct histindex *index, struct region *lcs,
 	int line1, int count1, int line2, int count2) {
 	int b_ptr;
@@ -343,10 +351,7 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
-	xdl_free(index.records);
-	xdl_free(index.line_map);
-	xdl_free(index.next_ptrs);
-	xdl_cha_free(&index.rcha);
+	free_index(&index);
 	return result;

  parent reply	other threads:[~2018-07-19 18:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 18:56 [PATCH 0/3] histogram diff: Fix memory ballooning in corner case Stefan Beller
2018-07-19 18:56 ` [PATCH 1/3] xdiff/xhistogram: pass arguments directly to fall_back_to_classic_diff Stefan Beller
2018-07-19 18:56 ` Stefan Beller [this message]
2018-07-19 18:56 ` [PATCH 3/3] xdiff/xhistogram: move index allocation into find_lcs Stefan Beller
2018-07-19 22:19   ` [PATCH] xdiff/histogram: remove tail recursion Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).