From f5c4c049bf8b6b246445a7e27361a16195c0b4ab Mon Sep 17 00:00:00 2001 From: Christian C Date: Wed, 2 Apr 2025 18:19:43 -0700 Subject: Remove temporary allocator --- lib/dir.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/dir.c') diff --git a/lib/dir.c b/lib/dir.c index f0776ca..dfc615b 100644 --- a/lib/dir.c +++ b/lib/dir.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -21,7 +20,7 @@ char **list_directory(char *dirname) { DIR *d; struct dirent *dir; d = opendir(dirname); - char **file_names = (char **)g_malloc(sizeof(char *)); + char **file_names = (char **)malloc(sizeof(char *)); if (file_names == NULL) { return NULL; } @@ -33,20 +32,20 @@ char **list_directory(char *dirname) { // When a regular file is reached /// Create space for it in the list char **temp = - g_realloc(file_names, (file_count + 1 + 1) * sizeof(char *)); + realloc(file_names, (file_count + 1 + 1) * sizeof(char *)); if (temp == NULL) { for (size_t file_idx = 0; file_idx < file_count; file_idx++) { - g_free(file_names[file_idx]); + free(file_names[file_idx]); } return NULL; } file_names = temp; /// Create space for the name file_names[file_count] = - g_calloc(strlen(dir->d_name) + 1, sizeof(char)); + calloc(strlen(dir->d_name) + 1, sizeof(char)); if (file_names[file_count] == NULL) { for (size_t file_idx = 0; file_idx < file_count; file_idx++) { - g_free(file_names[file_idx]); + free(file_names[file_idx]); } return NULL; } @@ -66,7 +65,7 @@ char *full_path(char *dir, char *file) { char *fpath = NULL; size_t dir_len = strlen(dir); size_t file_len = strlen(file); - fpath = (char *)g_calloc(dir_len + file_len + 2, sizeof(char)); + fpath = (char *)calloc(dir_len + file_len + 2, sizeof(char)); if (fpath == NULL) { return NULL; } -- cgit v1.2.1