freedir() shouldn't need to return anything

This commit is contained in:
Yorhel 2009-04-19 12:47:22 +02:00
parent d8058362ec
commit bb8c2e66e7
2 changed files with 8 additions and 17 deletions

View file

@ -176,8 +176,8 @@ void freedir_rec(struct dir *dr) {
}
struct dir *freedir(struct dir *dr) {
struct dir *tmp, *cur;
void freedir(struct dir *dr) {
struct dir *tmp;
/* update sizes of parent directories */
tmp = dr;
@ -187,33 +187,24 @@ struct dir *freedir(struct dir *dr) {
tmp->items -= dr->items+1;
}
/* free dr->sub recursive */
if(dr->sub) freedir_rec(dr->sub);
/* free dr->sub recursively */
if(dr->sub)
freedir_rec(dr->sub);
/* update references */
cur = NULL;
if(dr->parent) {
/* 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;
cur = dr->next;
}
/* else, get the previous item and update it's "next"-reference */
else
for(tmp = dr->parent->sub; tmp != NULL; tmp = tmp->next)
if(tmp->next == dr) {
if(tmp->next == dr)
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);
return cur;
}

View file

@ -72,7 +72,7 @@ char *formatsize(const off_t);
char *fullsize(const off_t);
/* recursively free()s a directory tree */
struct dir *freedir(struct dir *);
void freedir(struct dir *);
/* generates full path from a dir item */
char *getpath(struct dir *, char *);