Mercurial > hg > th-libs
comparison th_regex.c @ 712:838189b856f3
Fix various memory leaks in th_regex. Not that it is usable anyway yet.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 27 Apr 2020 01:31:53 +0300 |
parents | c91902120e79 |
children | c834e1393eb0 |
comparison
equal
deleted
inserted
replaced
711:c91902120e79 | 712:838189b856f3 |
---|---|
706 goto out; | 706 goto out; |
707 | 707 |
708 out: | 708 out: |
709 *pexpr = ctx.data; | 709 *pexpr = ctx.data; |
710 | 710 |
711 // Free temporary buffers | 711 // Free parse context |
712 for (size_t n = 0; n < ctx.nstack; n++) | |
713 { | |
714 if (ctx.stack[n] != ctx.data) | |
715 { | |
716 th_regex_free(ctx.stack[n]); | |
717 th_free(ctx.stack[n]); | |
718 } | |
719 } | |
720 th_free(ctx.stack); | |
721 | |
712 th_free(tmp); | 722 th_free(tmp); |
713 th_free(ctx.buf); | 723 th_free(ctx.buf); |
714 return res; | 724 return res; |
715 } | 725 } |
716 | 726 |
734 th_regex_free(node->match.expr); | 744 th_regex_free(node->match.expr); |
735 th_regex_list_free(&node->match.list); | 745 th_regex_list_free(&node->match.list); |
736 } | 746 } |
737 | 747 |
738 th_free(expr->nodes); | 748 th_free(expr->nodes); |
749 th_free(expr); | |
739 } | 750 } |
740 } | 751 } |
741 | 752 |
742 | 753 |
743 static void th_regex_dump_indent(th_ioctx *fh, const int level) | 754 static void th_regex_dump_indent(th_ioctx *fh, const int level) |
1184 * | 1195 * |
1185 * @param[in] matches structure to be deallocated | 1196 * @param[in] matches structure to be deallocated |
1186 */ | 1197 */ |
1187 void th_regex_free_matches(th_regex_match_t *matches) | 1198 void th_regex_free_matches(th_regex_match_t *matches) |
1188 { | 1199 { |
1189 th_llist_free_func_node((th_llist_t *) matches, | 1200 th_llist_free_func_data((th_llist_t *) matches, |
1190 (void (*)(th_llist_t *)) th_regex_free_match); | 1201 (void (*)(void *)) th_regex_free_match); |
1191 } | 1202 } |