]> Devi Nivas Git - cs3210-lab0.git/commitdiff
more name cleanup
authorrsc <rsc>
Sun, 16 Jul 2006 02:04:58 +0000 (02:04 +0000)
committerrsc <rsc>
Sun, 16 Jul 2006 02:04:58 +0000 (02:04 +0000)
fd.c
fd.h

diff --git a/fd.c b/fd.c
index 68f75e370c0cdcb0d1aefd81361f8dea5bfc3bf0..ce2931b895ba769e9d38dcb2a59044bc8ef6f268 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -37,7 +37,7 @@ fd_alloc()
   for(i = 0; i < NFD; i++){
     if(fds[i].type == FD_CLOSED){
       fds[i].type = FD_NONE;
-      fds[i].count = 1;
+      fds[i].ref = 1;
       release(&fd_table_lock);
       return fds + i;
     }
@@ -80,18 +80,16 @@ fd_close(struct fd *fd)
 {
   acquire(&fd_table_lock);
 
-  if(fd->count < 1 || fd->type == FD_CLOSED)
+  if(fd->ref < 1 || fd->type == FD_CLOSED)
     panic("fd_close");
 
-  fd->count -= 1;
-
-  if(fd->count == 0){
+  if(--fd->ref == 0){
     if(fd->type == FD_PIPE){
       pipe_close(fd->pipe, fd->writeable);
     } else {
       panic("fd_close");
     }
-    fd->count = 0;
+    fd->ref = 0;
     fd->type = FD_CLOSED;
   }
   
@@ -102,8 +100,8 @@ void
 fd_incref(struct fd *fd)
 {
   acquire(&fd_table_lock);
-  if(fd->count < 1 || fd->type == FD_CLOSED)
-    panic("fd_reference");
-  fd->count++;
+  if(fd->ref < 1 || fd->type == FD_CLOSED)
+    panic("fd_incref");
+  fd->ref++;
   release(&fd_table_lock);
 }
diff --git a/fd.h b/fd.h
index c8d0c340011cef238effc49ff63e837d0787f94a..aa03af9a233dd869336131d63e65f37952ed8c2c 100644 (file)
--- a/fd.h
+++ b/fd.h
@@ -1,6 +1,6 @@
 struct fd {
   enum { FD_CLOSED, FD_NONE, FD_PIPE } type;
-  int count; // reference count
+  int ref; // reference count
   char readable;
   char writeable;
   struct pipe *pipe;