aboutsummaryrefslogtreecommitdiff
path: root/index.c
diff options
context:
space:
mode:
authorarf20 <aruizfernandez05@gmail.com>2025-12-02 21:36:03 +0100
committerarf20 <aruizfernandez05@gmail.com>2025-12-02 21:36:03 +0100
commite3fd95c7a599aedb8798ab27813d2457d99be3b3 (patch)
tree1a31c4ecc5072e90e84b4c90097f25fc4d28ce64 /index.c
parentf982fb95044581435e31c765487b45d5ee963519 (diff)
downloadarfnet2-search-e3fd95c7a599aedb8798ab27813d2457d99be3b3.tar.gz
arfnet2-search-e3fd95c7a599aedb8798ab27813d2457d99be3b3.zip
generating results
Diffstat (limited to 'index.c')
-rw-r--r--index.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/index.c b/index.c
index 57c05d7..3430178 100644
--- a/index.c
+++ b/index.c
@@ -171,6 +171,7 @@ index_recurse(size_t size, const char *dir, int examine, size_t rootlen)
/* stat it */
node_data_t *data = malloc(sizeof(node_data_t));
+ memset(data, 0, sizeof(node_data_t));
data->name = strdup(de->d_name);
data->path = strdup(&path[rootlen]);
if (stat(path, &data->stat) < 0) {
@@ -182,11 +183,13 @@ index_recurse(size_t size, const char *dir, int examine, size_t rootlen)
/* examine */
if (examine) {
- data->mime = magic_file(magic_cookie, path);
- if (!data->mime)
+ const char *mime = magic_file(magic_cookie, path);
+ if (!mime) {
fprintf(stderr, "[index] error magic_file() %s: %s\n", path,
magic_error(magic_cookie));
- }
+ } else
+ data->mime = strdup(mime);
+ }
/* recurse */
map_t *child = NULL;