xdiff/xhistogram: factor out memory cleanup into free_index()

This will be useful in the next patch as we'll introduce multiple callers. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Jul 19, 2018 at 11:56 UTC c671d4b5990f07ca40b0914ca9be65c626608fca
1 file changed +9 -4
xdiff/xhistogram.c
+9 -4
@@ -243,6 +243,14 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
243 line1, count1, line2, count2);
244 }
245
246 +static inline void free_index(struct histindex *index)
247 +{
248 + xdl_free(index->records);
249 + xdl_free(index->line_map);
250 + xdl_free(index->next_ptrs);
251 + xdl_cha_free(&index->rcha);
252 +}
253 +
254 static int find_lcs(struct histindex *index, struct region *lcs,
255 int line1, int count1, int line2, int count2) {
256 int b_ptr;
@@ -343,10 +351,7 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
351 }
352
353 cleanup:
346 - xdl_free(index.records);
347 - xdl_free(index.line_map);
348 - xdl_free(index.next_ptrs);
349 - xdl_cha_free(&index.rcha);
354 + free_index(&index);
355
356 return result;
357 }