summaryrefslogtreecommitdiff
path: root/sources.c
diff options
context:
space:
mode:
Diffstat (limited to 'sources.c')
-rw-r--r--sources.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sources.c b/sources.c
index 3defa73..0963bc9 100644
--- a/sources.c
+++ b/sources.c
@@ -5,7 +5,7 @@
#include "maje.h"
-static char **filelist = NULL;
+static struct majefile **filelist = NULL;
static size_t nfiles = 0;
static int addfile(const char *path, const struct stat *st, int flags, struct FTW *ft)
@@ -17,21 +17,24 @@ static int addfile(const char *path, const struct stat *st, int flags, struct FT
}
if (strcmp(path + strlen(path) - 2, ".c") == 0) {
- char **tmp = realloc(filelist, sizeof(*filelist) * (nfiles + 2));
+ struct majefile **tmp = realloc(filelist, sizeof(*filelist) * (nfiles + 2));
if (tmp == NULL) {
return 1;
}
filelist = tmp;
- filelist[nfiles] = strdup(path);
- filelist[nfiles + 1] = NULL;
+ filelist[nfiles] = malloc(sizeof(*filelist[nfiles]) + strlen(path) + 1);
+
+ filelist[nfiles]->st = *st;
+ strcpy(filelist[nfiles]->path, strdup(path));
+ //filelist[nfiles + 1] = NULL;
nfiles++;
}
return 0;
}
-char ** find_source_files(const char *dir)
+struct majefile ** find_source_files(const char *dir)
{
nftw(dir, addfile, -1, 0);
return filelist;