Fix memory leaks

This commit is contained in:
2025-11-28 19:14:43 +00:00
parent ae5da6b38e
commit 5d0b789402
7 changed files with 167 additions and 117 deletions

View File

@@ -79,9 +79,24 @@ struct Inst {
int idx;
};
struct Thread {
Inst *pc;
uint32_t saved[40]; /* $0 through $9 */
};
struct ThreadList {
Thread *t;
int n;
};
Exp *regex_to_ast(std::string pattern);
void free_exp(Exp *exp);
Inst *compile_ast(Exp *root);
Inst *compile_regex(std::string pattern);
int next_match(Inst *prog, ByteIterator *it, uint32_t *saved);
int proglen(Inst *prog);
void free_program(Inst *instructions);
int next_match(Inst *prog, ByteIterator *it, uint32_t *saved, ThreadList *clist,
ThreadList *nlist);
void print_program(Inst *program);
#endif