From: skachman AT unl DOT edu (Steve Kachman) Subject: Patches for close and closedir 27 Jun 1997 13:06:52 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <3.0.1.32.19970627143645.007b3d00.cygnus.gnu-win32@unlinfo.unl.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Sender: skachman AT unlinfo DOT unl DOT edu X-Mailer: Windows Eudora Light Version 3.0.1 (32) Original-To: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com 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 skachman AT unl DOT edu - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".