Skip to content

Commit c671d4b

Browse files
stefanbellergitster
authored andcommitted
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>
1 parent 2820985 commit c671d4b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

xdiff/xhistogram.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@ static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
243243
line1, count1, line2, count2);
244244
}
245245

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+
246254
static int find_lcs(struct histindex *index, struct region *lcs,
247255
int line1, int count1, int line2, int count2) {
248256
int b_ptr;
@@ -343,10 +351,7 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
343351
}
344352

345353
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);
350355

351356
return result;
352357
}

0 commit comments

Comments
 (0)