aboutsummaryrefslogtreecommitdiff
path: root/lib/dir.c
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-04-01 20:46:17 -0700
committerChristian C <cc@localhost>2025-04-01 20:46:17 -0700
commitec7436a01deb8e28743de47ad98950c914d6da2a (patch)
tree765212b89d5c9740408d3d8bda8e1daacf55890e /lib/dir.c
parenta18cea2fef7aa1545c9a984b60919541b26a6f84 (diff)
Global Allocator Checking
Diffstat (limited to 'lib/dir.c')
-rw-r--r--lib/dir.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/dir.c b/lib/dir.c
index 7200c52..361775d 100644
--- a/lib/dir.c
+++ b/lib/dir.c
@@ -1,5 +1,6 @@
#include <dirent.h>
#include <lib/dir.h>
+#include <lib/mem/galloc.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
@@ -20,7 +21,7 @@ char **list_directory(char *dirname) {
DIR *d;
struct dirent *dir;
d = opendir(dirname);
- char **file_names = (char **)malloc(sizeof(char *));
+ char **file_names = (char **)g_malloc(sizeof(char *));
if (!file_names) {
return NULL;
}
@@ -33,7 +34,8 @@ char **list_directory(char *dirname) {
/// Create space for it in the list
file_names = realloc(file_names, (file_count + 1 + 1) * sizeof(char *));
/// Create space for the name
- file_names[file_count] = calloc(strlen(dir->d_name) + 1, sizeof(char));
+ file_names[file_count] =
+ g_calloc(strlen(dir->d_name) + 1, sizeof(char));
/// Copy the name
strcpy(file_names[file_count], dir->d_name);
/// Mark the end of the file list with a NULL entry
@@ -50,7 +52,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 *)calloc(dir_len + file_len + 2, sizeof(char));
+ fpath = (char *)g_calloc(dir_len + file_len + 2, sizeof(char));
strcpy(fpath, dir);
strcpy(fpath + dir_len + 1, file);
fpath[dir_len] = '/';