diff src/event-msw.c @ 560:b202fbfc7dea

[xemacs-hg @ 2001-05-23 11:29:58 by ben] event-msw.c: prior kludgy code was clobbering the buffer, thinking it was "unused" space to store an unneeded return value; instead, use the variable we've already got staring us in the face.
author ben
date Wed, 23 May 2001 11:30:01 +0000
parents ed498ef2108b
children 183866b06e0b
line wrap: on
line diff
--- a/src/event-msw.c	Wed May 23 10:02:19 2001 +0000
+++ b/src/event-msw.c	Wed May 23 11:30:01 2001 +0000
@@ -782,10 +782,10 @@
   str->buffer = xrealloc (str->buffer, size);
   memcpy (str->buffer, data, size);
 
-  /* Docs indicate that 4th parameter to WriteFile can be NULL since this is
-   * an overlapped operation. This fails on Win95 with winsock 1.x so we
-   * supply a spare address which is ignored by Win95 anyway. Sheesh. */
-  if (WriteFile ((HANDLE)str->s, str->buffer, size, (LPDWORD)&str->buffer,
+  /* According to MSDN WriteFile docs, the fourth parameter cannot be NULL
+     on Win95 even when doing an overlapped operation, as we are, where
+     the return value through that parameter is not meaningful. */
+  if (WriteFile ((HANDLE)str->s, str->buffer, size, &str->bufsize,
 		 &str->ov)
       || GetLastError() == ERROR_IO_PENDING)
     str->pending_p = 1;
@@ -810,7 +810,10 @@
     WaitForSingleObject (str->ov.hEvent, INFINITE);
 
   if (str->buffer)
-    xfree (str->buffer);
+    {
+      xfree (str->buffer);
+      str->buffer = 0;
+    }
 
   CloseHandle (str->ov.hEvent);
   return 0;