cleaner memory management

This commit is contained in:
anon
2024-09-15 02:39:52 +02:00
parent 813003c793
commit 3bd051183b
3 changed files with 19 additions and 4 deletions

View File

@ -114,10 +114,6 @@ identifier [a-zA-z][a-zA-z0-9_]*
%%
char * tbsp_c_expland_code(const char * const s) {
kv_init(query);
buffer = sdsnew("");
query_string_buffer = sdsnew("");
YY_BUFFER_STATE const b = yy_scan_string(s);
tbsp_c_lex();
tbsp_c__delete_buffer(b);
@ -137,3 +133,17 @@ char * expand_c_query(void) {
return r;
}
int tbsp_c_yy_init(void) {
kv_init(query);
buffer = sdsnew("");
query_string_buffer = sdsnew("");
return 0;
}
int tbsp_c_yy_deinit(void) {
tbsp_c__delete_buffer(YY_CURRENT_BUFFER);
sdsfree(buffer);
sdsfree(query_string_buffer);
return 0;
}