[WS2_32]
authorCameron Gutman <aicommander@gmail.com>
Thu, 8 Dec 2011 19:29:20 +0000 (19:29 +0000)
committerCameron Gutman <aicommander@gmail.com>
Thu, 8 Dec 2011 19:29:20 +0000 (19:29 +0000)
- Store WSAPROTOCOL_INFOW struct on the stack

svn path=/trunk/; revision=54616

reactos/dll/win32/ws2_32/misc/ns.c

index 6370b0f..adea2bb 100644 (file)
@@ -371,7 +371,7 @@ WSAStringToAddressA(IN     LPSTR AddressString,
 {
     INT ret, len;
     LPWSTR szTemp;
 {
     INT ret, len;
     LPWSTR szTemp;
-    LPWSAPROTOCOL_INFOW lpProtoInfoW = NULL;
+    WSAPROTOCOL_INFOW ProtoInfoW;
 
     len = MultiByteToWideChar(CP_ACP,
                               0,
 
     len = MultiByteToWideChar(CP_ACP,
                               0,
@@ -393,13 +393,7 @@ WSAStringToAddressA(IN     LPSTR AddressString,
 
     if (lpProtocolInfo)
     {
 
     if (lpProtocolInfo)
     {
-        len = WSAPROTOCOL_LEN+1;
-        lpProtoInfoW = HeapAlloc(GetProcessHeap(),
-                                 0,
-                                 FIELD_OFFSET(WSAPROTOCOL_INFOW, szProtocol) +
-                                 (len * sizeof(WCHAR)));
-
-        memcpy(lpProtoInfoW,
+        memcpy(&ProtoInfoW,
                lpProtocolInfo,
                FIELD_OFFSET(WSAPROTOCOL_INFOA, szProtocol));
 
                lpProtocolInfo,
                FIELD_OFFSET(WSAPROTOCOL_INFOA, szProtocol));
 
@@ -407,13 +401,13 @@ WSAStringToAddressA(IN     LPSTR AddressString,
                             0,
                             lpProtocolInfo->szProtocol,
                             -1,
                             0,
                             lpProtocolInfo->szProtocol,
                             -1,
-                            lpProtoInfoW->szProtocol,
-                            len);
+                            ProtoInfoW.szProtocol,
+                            WSAPROTOCOL_LEN + 1);
     }
 
     ret = WSAStringToAddressW(szTemp,
                               AddressFamily,
     }
 
     ret = WSAStringToAddressW(szTemp,
                               AddressFamily,
-                              lpProtoInfoW,
+                              &ProtoInfoW,
                               lpAddress,
                               lpAddressLength);
 
                               lpAddress,
                               lpAddressLength);
 
@@ -421,11 +415,6 @@ WSAStringToAddressA(IN     LPSTR AddressString,
              0,
              szTemp );
 
              0,
              szTemp );
 
-    if (lpProtocolInfo)
-        HeapFree(GetProcessHeap(),
-                 0,
-                 lpProtoInfoW);
-
     WSASetLastError(ret);
     return ret;
 }
     WSASetLastError(ret);
     return ret;
 }