Moved pattern code into the right file
This commit is contained in:
parent
13c4564594
commit
3d3a73e18c
21
match.c
21
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
|
||||
|
2
match.h
2
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);
|
||||
|
21
pattern.c
21
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
|
||||
|
Loading…
Reference in New Issue
Block a user