@matheusbsbs / matheus-bagliano / commits / 8cfe5f1cd5
Fork 0

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 <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jul 2, 2009 at 00:01 UTC 8cfe5f1cd5dabc3a21bc792327747deefeff6dff
3 files changed +17
diff.c
+1
@@ -1603,6 +1603,7 @@ static void builtin_diff(const char *name_a,
1603 free(mf1.ptr);
1604 if (textconv_two)
1605 free(mf2.ptr);
1606 + xdiff_clear_find_func(&xecfg);
1607 }
1608
1609 free_ab_and_return:
xdiff-interface.c
+15
@@ -309,6 +309,21 @@ void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)
309 }
310 }
311
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 +
327 int git_xmerge_style = -1;
328
329 int git_xmerge_config(const char *var, const char *value, void *cb)
xdiff-interface.h
+1
@@ -21,6 +21,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename);
21 int buffer_is_binary(const char *ptr, unsigned long size);
22
23 extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);
24 +extern void xdiff_clear_find_func(xdemitconf_t *xecfg);
25 extern int git_xmerge_config(const char *var, const char *value, void *cb);
26 extern int git_xmerge_style;
27