[WRITER] Emperifollada para que no sea nasty cranky

This commit is contained in:
fsandalinas 2022-09-18 02:36:11 +00:00
parent 2300564600
commit 319ce32107
3 changed files with 42 additions and 3 deletions

View File

@ -61,5 +61,8 @@ lst_next(struct lst **l);
void
read_mem(u8 *mem);
void
lst_free(struct lst *l);
#define util_hfran
#endif

View File

@ -46,3 +46,15 @@ lst_next(struct lst **l) {
*l = n;
return element;
}
void
lst_free(struct lst *l) {
if (l->size == 0) {
free(l);
return;
} else {
lst_free(l);
free(l);
return;
}
}

View File

@ -321,17 +321,41 @@ test() {
assert((*(int *)lst_next(&it)) == a);
}
int
main() {
test();
void
free_lists() {
struct lst *it = lbl_ref_list;
while(it->size > 0) {
free(it->e);
}
it = lbl_def_list;
while(it->size > 0) {
free(it->e);
}
lst_free(lbl_ref_list);
lst_free(lbl_def_list);
}
void
init_lists() {
lbl_ref_list = calloc(sizeof(struct lst), 1);
lbl_def_list = calloc(sizeof(struct lst), 1);
lst_init(lbl_ref_list);
lst_init(lbl_def_list);
}
int
main() {
test();
buff_init(&file_buff);
while (quit == 0) {
prgm();
}
out_file();
free_lists();
buff_free(&file_buff);
return 0;
}