Skip to content
Snippets Groups Projects
Commit bb8c2e66 authored by Yorhel's avatar Yorhel
Browse files

freedir() shouldn't need to return anything

parent d8058362
No related branches found
No related tags found
No related merge requests found
...@@ -176,8 +176,8 @@ void freedir_rec(struct dir *dr) { ...@@ -176,8 +176,8 @@ void freedir_rec(struct dir *dr) {
} }
struct dir *freedir(struct dir *dr) { void freedir(struct dir *dr) {
struct dir *tmp, *cur; struct dir *tmp;
/* update sizes of parent directories */ /* update sizes of parent directories */
tmp = dr; tmp = dr;
...@@ -187,33 +187,24 @@ struct dir *freedir(struct dir *dr) { ...@@ -187,33 +187,24 @@ struct dir *freedir(struct dir *dr) {
tmp->items -= dr->items+1; tmp->items -= dr->items+1;
} }
/* free dr->sub recursive */ /* free dr->sub recursively */
if(dr->sub) freedir_rec(dr->sub); if(dr->sub)
freedir_rec(dr->sub);
/* update references */ /* update references */
cur = NULL;
if(dr->parent) { if(dr->parent) {
/* item is at the top of the dir, refer to next item */ /* item is at the top of the dir, refer to next item */
if(dr->parent->sub == dr) { if(dr->parent->sub == dr)
dr->parent->sub = dr->next; dr->parent->sub = dr->next;
cur = dr->next;
}
/* else, get the previous item and update it's "next"-reference */ /* else, get the previous item and update it's "next"-reference */
else else
for(tmp = dr->parent->sub; tmp != NULL; tmp = tmp->next) for(tmp = dr->parent->sub; tmp != NULL; tmp = tmp->next)
if(tmp->next == dr) { if(tmp->next == dr)
tmp->next = dr->next; tmp->next = dr->next;
cur = tmp;
}
/* no previous item, refer to parent dir */
if(cur == NULL && dr->parent->parent)
cur = dr->parent;
} }
free(dr->name); free(dr->name);
free(dr); free(dr);
return cur;
} }
......
...@@ -72,7 +72,7 @@ char *formatsize(const off_t); ...@@ -72,7 +72,7 @@ char *formatsize(const off_t);
char *fullsize(const off_t); char *fullsize(const off_t);
/* recursively free()s a directory tree */ /* recursively free()s a directory tree */
struct dir *freedir(struct dir *); void freedir(struct dir *);
/* generates full path from a dir item */ /* generates full path from a dir item */
char *getpath(struct dir *, char *); char *getpath(struct dir *, char *);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment