From 37f3c2b6f54f75b6fba63ede6fc5beaa9d26dd56 Mon Sep 17 00:00:00 2001 From: a bellenir Date: Sun, 20 Jul 2014 23:50:44 +0000 Subject: [PATCH] free vfiles --- source/workdir.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/workdir.c b/source/workdir.c index 211efa6..1277a8c 100644 --- a/source/workdir.c +++ b/source/workdir.c @@ -44,7 +44,7 @@ void workdir_init(int windex) { void workdir_next(void) { int index = state_get_focused_frame(); //do nothing if at the end of the file list - if(Windows[index].idx < vec_size(Windows[index].vfiles)){ + if(Windows[index].idx < vec_size(Windows[index].vfiles)-1){ Windows[index].idx += 1; int rows,cols; getmaxyx(stdscr, rows,cols); @@ -122,8 +122,10 @@ void workdir_ls(void) { static void get_files(int windex){ int i=0; - //TODO: free vfiles - Windows[windex].vfiles = vec_new(1, ".."); /* TODO: check if cwd = / */ + if(Windows[windex].vfiles) mem_release(Windows[windex].vfiles); + char* dotdot = mem_allocate(sizeof(char)*3, dumdestruct); + strcpy(dotdot, ".."); + Windows[windex].vfiles = vec_new(1, dotdot); /* TODO: check if cwd = / */ char cmd[1028] = "ls "; strcpy(&cmd[3], Windows[windex].cwd); FILE* ls = popen(cmd, "r"); -- 2.49.0