Skip to content

Commit 8cfe5f1

Browse files
René Scharfegitster
authored andcommitted
userdiff: add xdiff_clear_find_func()
xdiff_set_find_func() is used to set user defined regular expressions for finding function signatures. Add xdiff_clear_find_func(), which frees the memory allocated by the former, making the API complete. Also, use the new function in diff.c (the only call site of xdiff_set_find_func()) to clean up after ourselves. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 725cf7b commit 8cfe5f1

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,7 @@ static void builtin_diff(const char *name_a,
16031603
free(mf1.ptr);
16041604
if (textconv_two)
16051605
free(mf2.ptr);
1606+
xdiff_clear_find_func(&xecfg);
16061607
}
16071608

16081609
free_ab_and_return:

xdiff-interface.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,21 @@ void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)
309309
}
310310
}
311311

312+
void xdiff_clear_find_func(xdemitconf_t *xecfg)
313+
{
314+
if (xecfg->find_func) {
315+
int i;
316+
struct ff_regs *regs = xecfg->find_func_priv;
317+
318+
for (i = 0; i < regs->nr; i++)
319+
regfree(&regs->array[i].re);
320+
free(regs->array);
321+
free(regs);
322+
xecfg->find_func = NULL;
323+
xecfg->find_func_priv = NULL;
324+
}
325+
}
326+
312327
int git_xmerge_style = -1;
313328

314329
int git_xmerge_config(const char *var, const char *value, void *cb)

xdiff-interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename);
2121
int buffer_is_binary(const char *ptr, unsigned long size);
2222

2323
extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);
24+
extern void xdiff_clear_find_func(xdemitconf_t *xecfg);
2425
extern int git_xmerge_config(const char *var, const char *value, void *cb);
2526
extern int git_xmerge_style;
2627

0 commit comments

Comments
 (0)