Changed how the '/' is printed after dir names.
authorFrancois Fleuret <francois@fleuret.org>
Sun, 6 Mar 2011 09:44:27 +0000 (10:44 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Sun, 6 Mar 2011 09:44:27 +0000 (10:44 +0100)
dus.c

diff --git a/dus.c b/dus.c
index 872f5c1..9330ebd 100644 (file)
--- a/dus.c
+++ b/dus.c
@@ -188,13 +188,14 @@ struct entry_node {
 };
 
 struct entry_node *push_entry(char *name, struct entry_node *head) {
+  char tmp_name[PATH_MAX];
   struct entry_node *result;
   int isdir;
   result = safe_malloc(sizeof(struct entry_node));
   result->size = entry_size(name, &isdir);
   if(isdir) {
-    result->name = safe_malloc(sizeof(char) * strlen(name) + 2);
-    sprintf(result->name, "%s/", name);
+    snprintf(tmp_name, PATH_MAX, "%s/", name);
+    result->name = strdup(tmp_name);
   } else {
     result->name = strdup(name);
   }