Subject: Patches for close and closedir
From: [email-masked] (Steve Kachman)

27 Jun 1997 13:06:52 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Sender: [email-masked]
X-Mailer: Windows Eudora Light Version 3.0.1 (32)
Original-To: [email-masked]
Original-Sender: [email-masked]

When a file is open it allocates memory for the name of the file. However,
when the file is closed it does not free this memory. I also patched dup,
to avoid freeing the memory twice and/or freeing it before everyone was
done. I am not sure if this is the correct thing to do, but it is working
for me. 

In addition, I made a small patch to closedir to handle the case when
readdir has not been called.

diff -b -C4 -x*.[ao] -x*~ -xMakefile -xc* -x*.out -x*.dll
/tmp/cdk/winsup/dirsearch.cc winsup/dirsearch.cc
*** /tmp/cdk/winsup/dirsearch.cc	Thu Apr 24 18:45:35 1997
--- winsup/dirsearch.cc	Thu Jun 26 14:09:13 1997
***************
*** 176,184 ****
        syscall_printf ("-1 = closedir (%p)\n", dir);
        return -1;
      }
  
!   if (FindClose (dir->__d_u.__d_data.__handle) == 0)
      {
        __seterrno ();
        syscall_printf ("-1 = closedir (%p)\n", dir);
        return -1;
--- 176,186 ----
        syscall_printf ("-1 = closedir (%p)\n", dir);
        return -1;
      }
  
!   if (
!       dir->__d_find_first_called &&                   // Added by SDK
!       (FindClose (dir->__d_u.__d_data.__handle) == 0))
      {
        __seterrno ();
        syscall_printf ("-1 = closedir (%p)\n", dir);
        return -1;
Common subdirectories: /tmp/cdk/winsup/doc and winsup/doc
diff -b -C4 -x*.[ao] -x*~ -xMakefile -xc* -x*.out -x*.dll
/tmp/cdk/winsup/fhandler.cc winsup/fhandler.cc
*** /tmp/cdk/winsup/fhandler.cc	Tue Apr 29 15:33:31 1997
--- winsup/fhandler.cc	Thu Jun 26 09:22:09 1997
***************
*** 773,780 ****
--- 773,786 ----
        else
  	{
  	  if (type == FILE_TYPE_DISK)
  	    process_deletion_queue ();
+ 	  
+ 	  if (unix_path_name_ != 0)        // Added by SDK
+ 	    {                              // Added by SDK
+ 	      delete [] unix_path_name_;   // Added by SDK
+ 	      unix_path_name_=0;           // Added by SDK
+ 	    }                              // Added by SDK
  	  res = 0;
  	  set_handle((HANDLE)-99);
  	}
      }
***************
*** 929,936 ****
--- 935,945 ----
        return -1;
      }
  
    child->set_handle(nh);
+ 
+   child->unix_path_name_=0;         // Added by SDK
+   child->set_name(unix_path_name_); // Added by SDK
    return 0;
  }
  
  /*
Common subdirectories: /tmp/cdk/winsup/glob and winsup/glob
Common subdirectories: /tmp/cdk/winsup/include and winsup/include
Common subdirectories: /tmp/cdk/winsup/sysdef and winsup/sysdef
Common subdirectories: /tmp/cdk/winsup/utils and winsup/utils

Steve Kachman
[email-masked]

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".