From 832549892a4ca2b25eafbcc2382f110bbc05b060 Mon Sep 17 00:00:00 2001 From: abellenir Date: Sat, 26 Jul 2014 06:58:23 +0000 Subject: [PATCH] remove unnecessary variable --- source/workdir.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/source/workdir.c b/source/workdir.c index 4e1ff2d..4f6b9dc 100644 --- a/source/workdir.c +++ b/source/workdir.c @@ -130,19 +130,17 @@ void workdir_ls(WorkDir_T* wd){ wd->vfiles = vec_new(0); if(dd) vec_push_back(wd->vfiles, dd); while ((read = getline(&filename, &len, ls)) != -1){ - char* fullpath = mem_allocate((pathlength+read+1)*sizeof(char), NULL); - int filename_offset = pathlength; File_T* file = mem_allocate(sizeof(File_T), &file_free); + file->path = mem_allocate((pathlength+read+1)*sizeof(char), NULL); + int filename_offset = pathlength; filename[read-1]=0; //remove ending newline //build full path: - strcpy(fullpath, wd->path); + strcpy(file->path, wd->path); if (wd->path[pathlength-1] != '/') { - strcat(fullpath, "/"); + strcat(file->path, "/"); filename_offset += 1; } - strcat(fullpath, filename); - //build file: - file->path = fullpath; + strcat(file->path, filename); file->name = &(file->path[filename_offset]); vec_push_back(wd->vfiles, file); } -- 2.49.0