diff --git a/src/regex/match_struct.c b/src/regex/match_struct.c index 3d3024f..649490c 100644 --- a/src/regex/match_struct.c +++ b/src/regex/match_struct.c @@ -43,3 +43,9 @@ RegexCapture* RegexMatch_GetNumberedCapture(RegexMatch* match, size_t number) return DynamicArray_GetPointer(&match->captures, capture_index); } + +void RegexMatch_Destroy(RegexMatch* match) +{ + DynamicArray_Destroy(&match->captures); + match->match = STRINGVIEW_NONE; +} diff --git a/src/regex/match_struct.h b/src/regex/match_struct.h index de03ebb..7d1ec92 100644 --- a/src/regex/match_struct.h +++ b/src/regex/match_struct.h @@ -26,4 +26,6 @@ typedef struct RegexMatch_s { bool RegexMatch_HaveNumberedCapture(RegexMatch* match, size_t number); RegexCapture* RegexMatch_GetNumberedCapture(RegexMatch* match, size_t number); +void RegexMatch_Destroy(RegexMatch* match); + #endif diff --git a/tests/regex.test.c b/tests/regex.test.c index b830f38..b4bf432 100644 --- a/tests/regex.test.c +++ b/tests/regex.test.c @@ -31,6 +31,8 @@ void testLiteral(void) assert(Regex_FirstMatch(®ex, test_string_0, &match) == EXIT_SUCCESS); assert(StringView_Equal(match.match, test_string_0)); + RegexMatch_Destroy(&match); + Regex_Destroy(®ex); assert(allocator.reserved == 0); Allocator_DestroySystemAllocator(&allocator); @@ -52,6 +54,8 @@ void testBackslash(void) assert(Regex_FirstMatch(®ex, match_string, &match) == EXIT_SUCCESS); assert(StringView_Equal(match.match, match_string)); + RegexMatch_Destroy(&match); + Regex_Destroy(®ex); assert(allocator.reserved == 0); Allocator_DestroySystemAllocator(&allocator);