Skip to content

Commit

Permalink
file: implement proper ref counting
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 28, 2024
1 parent 2b97d6f commit a05da13
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ int closeFile(Thread *t, int fd) {

// TODO: flush the file buffers here to allow drivers to implement caching

file->refCount--;
if(!file->refCount) free(file);

closeIO(p, &p->io[fd]);
return 0;
}
Expand Down

0 comments on commit a05da13

Please sign in to comment.