Skip to content

Commit

Permalink
Memory leak fixed for printpath routine
Browse files Browse the repository at this point in the history
checked with `du -k /etc | valgrind --leak-check=full --show-leak-kinds=all ./xdu`
  • Loading branch information
niclas committed Aug 15, 2018
1 parent a374120 commit 5b0eb9b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions xdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,17 +696,21 @@ void printpath(int x, int y)
{
struct node *np;
char* path;
char* tmp_path;

np = findnode(&top, x, y);
if (np == NULL)
return;
path = np->name;
asprintf(&path, "%s", np->name);
while(np->parent != NULL) {
tmp_path = path;
asprintf(&path, "%s/%s", np->parent->name, path);
np = np->parent;
free(tmp_path);
}
path += 6;
printf("%s\n", path);
tmp_path = path + 6;
printf("%s\n", tmp_path);
free(path);
}

void reset(void)
Expand Down

0 comments on commit 5b0eb9b

Please sign in to comment.