cleaner memory management
This commit is contained in:
parent
813003c793
commit
3bd051183b
@ -20,6 +20,8 @@
|
||||
|
||||
extern int tbsp_yy_init(void);
|
||||
extern int tbsp_yy_deinit(void);
|
||||
extern int tbsp_c_yy_init(void);
|
||||
extern int tbsp_c_yy_deinit(void);
|
||||
|
||||
char * language = NULL;
|
||||
char * verbatim = NULL;
|
||||
@ -107,6 +109,7 @@ signed main(const int argc, const char * const * const argv) {
|
||||
|
||||
tbsp_yy_init();
|
||||
tbsp_tab_init();
|
||||
tbsp_c_yy_init();
|
||||
|
||||
CHECKED_FOPEN(yyin, input_file_name, "r");
|
||||
CHECKED_FOPEN(yyout, output_file_name, "w");
|
||||
@ -123,6 +126,7 @@ signed main(const int argc, const char * const * const argv) {
|
||||
}
|
||||
|
||||
tbsp_yy_deinit();
|
||||
tbsp_c_yy_deinit();
|
||||
free(output_file_name);
|
||||
free(input_file_name);
|
||||
free(verbatim);
|
||||
|
@ -94,6 +94,7 @@ int tbsp_yy_init(void) {
|
||||
}
|
||||
|
||||
int tbsp_yy_deinit(void) {
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||
sdsfree(buffer);
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user