Fix memory leak

This commit is contained in:
Night Kaly 2025-01-13 09:10:51 +00:00
parent 3c005f84f9
commit d6f9054bc0
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
3 changed files with 10 additions and 0 deletions

3
ccc.c
View file

@ -220,6 +220,7 @@ void handle_sigwinch(int ignore)
void cleanup(void)
{
hashtable_free();
if (files->length != 0) {
arraylist_free(files);
}
@ -547,6 +548,7 @@ void show_file_content(void)
int color = files_visit->items[i].color;
move_cursor(i + 1, half_width);
bprintf("\033[K\033[%dm%s\033[m\n", color, line);
free(line);
}
arraylist_free(files_visit);
return;
@ -565,6 +567,7 @@ void show_file_content(void)
return;
}
}
fclose(file);
int pipe_fd[2];
if (pipe(pipe_fd) == -1) {
perror("pipe");

View file

@ -187,3 +187,9 @@ icon *hashtable_search(char *name)
return NULL;
}
void hashtable_free(void)
{
for (int i = 0; i < TABLE_SIZE; i++)
free(hash_table[i]);
}

View file

@ -14,5 +14,6 @@ void hashtable_init(void);
void hashtable_print(void);
int hashtable_add(icon *p);
icon *hashtable_search(char *name);
void hashtable_free(void);
#endif