diff --git a/match.c b/match.c index 286c077..5b99bce 100644 --- a/match.c +++ b/match.c @@ -664,25 +664,4 @@ size_t free_all_matches(void) } #endif -// -// Deallocate memory referenced inside a pattern struct -// -void destroy_pat(pat_t *pat) -{ - switch (pat->type) { - case VM_STRING: case VM_REF: - xfree(&pat->args.s); - break; - case VM_CAPTURE: - if (pat->args.capture.name) - xfree(&pat->args.capture.name); - break; - case VM_REPLACE: - if (pat->args.replace.text) - xfree(&pat->args.replace.text); - break; - default: break; - } -} - // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1 diff --git a/match.h b/match.h index f297350..9530321 100644 --- a/match.h +++ b/match.h @@ -14,8 +14,6 @@ __attribute__((hot, nonnull(2,3,4))) match_t *match(def_t *defs, file_t *f, const char *str, pat_t *pat, unsigned int flags); __attribute__((nonnull)) match_t *get_capture(match_t *m, const char **id); -__attribute__((nonnull)) -void destroy_pat(pat_t *pat); match_t *new_match(void); __attribute__((nonnull)) void recycle_if_unused(match_t **at_m); diff --git a/pattern.c b/pattern.c index a065f3f..785e5ba 100644 --- a/pattern.c +++ b/pattern.c @@ -613,4 +613,25 @@ def_t *bp_definition(file_t *f, const char *str) return def; } +// +// Deallocate memory referenced inside a pattern struct +// +void destroy_pat(pat_t *pat) +{ + switch (pat->type) { + case VM_STRING: case VM_REF: + xfree(&pat->args.s); + break; + case VM_CAPTURE: + if (pat->args.capture.name) + xfree(&pat->args.capture.name); + break; + case VM_REPLACE: + if (pat->args.replace.text) + xfree(&pat->args.replace.text); + break; + default: break; + } +} + // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1 diff --git a/pattern.h b/pattern.h index 933eb83..c0a5ed4 100644 --- a/pattern.h +++ b/pattern.h @@ -19,6 +19,8 @@ __attribute__((nonnull)) pat_t *bp_pattern(file_t *f, const char *str); __attribute__((nonnull)) def_t *bp_definition(file_t *f, const char *str); +__attribute__((nonnull)) +void destroy_pat(pat_t *pat); #endif // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1