diff options
Diffstat (limited to 'src/libfs/fs.c')
-rw-r--r-- | src/libfs/fs.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libfs/fs.c b/src/libfs/fs.c index 31515250..a42af96b 100644 --- a/src/libfs/fs.c +++ b/src/libfs/fs.c @@ -86,19 +86,27 @@ fsunmount(Fsys *fs) void _fsdecref(Fsys *fs) { - Fid *f, *next; + Fid *f, **l, *next; qlock(&fs->lk); --fs->ref; //fprint(2, "fsdecref %p to %d\n", fs, fs->ref); if(fs->ref == 0){ close(fs->fd); + /* trim the list down to just the first in each chunk */ + for(l=&fs->freefid; *l; ){ + if((*l)->fid%Fidchunk == 0) + l = &(*l)->next; + else + *l = (*l)->next; + } + /* now free the list */ for(f=fs->freefid; f; f=next){ next = f->next; - if(f->fid%Fidchunk == 0) - free(f); + free(f); } free(fs); + return; } qunlock(&fs->lk); } |