From 02f7a54e67260ee7995c6cd9bf40ae784b60203d Mon Sep 17 00:00:00 2001 From: nirav Date: Wed, 5 Sep 2018 00:35:24 +0530 Subject: Added image panning support, refactoring --- file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 33d326b..528de4b 100644 --- a/file.c +++ b/file.c @@ -1,5 +1,6 @@ #include "file.h" #include +#include #include #include #include @@ -27,7 +28,6 @@ int scan(const char *file_name) { struct dirent **name_list; char *dir_name = dirname(strdup(file_name)); - size_t dir_name_len = strlen(dir_name); file_list_count = scandir(dir_name, &name_list, image_filter, alphasort); if (file_list_count < 0) { return -1; @@ -39,9 +39,7 @@ int scan(const char *file_name) while (i < file_list_count) { if (!strcmp(file_basename, name_list[i]->d_name)) curr_file_index = i; - file_list[i] = malloc( - (strlen(name_list[i]->d_name) + dir_name_len + 2) * sizeof(char *)); - sprintf(file_list[i], "%s/%s", dir_name, name_list[i]->d_name); + file_list[i] = g_build_filename(dir_name, name_list[i]->d_name, NULL); free(name_list[i]); i++; } -- cgit v1.2.3