Author: akhaldi
Date: Mon Oct 13 18:08:34 2014
New Revision: 64733

URL: http://svn.reactos.org/svn/reactos?rev=64733&view=rev
Log:
[CRT]
* Update free_fd().
* Fixes some msvcrt:file tests.
CORE-8540

Modified:
    trunk/reactos/lib/sdk/crt/stdio/file.c

Modified: trunk/reactos/lib/sdk/crt/stdio/file.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/file.c?rev=64733&r1=64732&r2=64733&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/file.c      [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/file.c      [iso-8859-1] Mon Oct 13 
18:08:34 2014
@@ -233,40 +233,37 @@
 /* INTERNAL: free a file entry fd */
 static void free_fd(int fd)
 {
-  HANDLE old_handle;
   ioinfo *fdinfo;
 
   LOCK_FILES();
   fdinfo = get_ioinfo(fd);
-  old_handle = fdinfo->handle;
   if(fdinfo != &__badioinfo)
   {
     fdinfo->handle = INVALID_HANDLE_VALUE;
     fdinfo->wxflag = 0;
   }
   TRACE(":fd (%d) freed\n",fd);
-  if (fd < 3) /* don't use 0,1,2 for user files */
+
+  if (fd < 3)
   {
     switch (fd)
     {
     case 0:
-        if (GetStdHandle(STD_INPUT_HANDLE) == old_handle) 
SetStdHandle(STD_INPUT_HANDLE, 0);
+        SetStdHandle(STD_INPUT_HANDLE, 0);
         break;
     case 1:
-        if (GetStdHandle(STD_OUTPUT_HANDLE) == old_handle) 
SetStdHandle(STD_OUTPUT_HANDLE, 0);
+        SetStdHandle(STD_OUTPUT_HANDLE, 0);
         break;
     case 2:
-        if (GetStdHandle(STD_ERROR_HANDLE) == old_handle) 
SetStdHandle(STD_ERROR_HANDLE, 0);
+        SetStdHandle(STD_ERROR_HANDLE, 0);
         break;
     }
   }
-  else
-  {
-    if (fd == fdend - 1)
-      fdend--;
-    if (fd < fdstart)
-      fdstart = fd;
-  }
+
+  if (fd == fdend - 1)
+    fdend--;
+  if (fd < fdstart)
+    fdstart = fd;
   UNLOCK_FILES();
 }
 


Reply via email to