[WINHTTP] Sync with Wine Staging 3.9. CORE-14656
[reactos.git] / dll / win32 / winhttp / handle.c
index 16bd601..6026a49 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
+#include "config.h"
+#include "wine/port.h"
+#include "wine/debug.h"
 
-#include <config.h>
-//#include "wine/port.h"
-#include <wine/debug.h>
+#include <stdarg.h>
 
-//#include <stdarg.h>
-
-//#include "windef.h"
-#include <winbase.h>
-#include <winhttp.h>
+#include "windef.h"
+#include "winbase.h"
+#include "winhttp.h"
 
 #include "winhttp_private.h"
 
@@ -93,9 +89,10 @@ void release_object( object_header_t *hdr )
 HINTERNET alloc_handle( object_header_t *hdr )
 {
     object_header_t **p;
-    ULONG_PTR handle = 0, num;
+    ULONG_PTR handle, num;
 
     list_init( &hdr->children );
+    hdr->handle = NULL;
 
     EnterCriticalSection( &handle_cs );
     if (!max_handles)
@@ -116,11 +113,12 @@ HINTERNET alloc_handle( object_header_t *hdr )
     if (handles[handle]) ERR("handle isn't free but should be\n");
 
     handles[handle] = addref_object( hdr );
-    while (handles[next_handle] && (next_handle < max_handles)) next_handle++;
+    hdr->handle = (HINTERNET)(handle + 1);
+    while ((next_handle < max_handles) && handles[next_handle]) next_handle++;
 
 end:
     LeaveCriticalSection( &handle_cs );
-    return hdr->handle = (HINTERNET)(handle + 1);
+    return hdr->handle;
 }
 
 BOOL free_handle( HINTERNET hinternet )