kernel32: Remove superfluous heap reallocation calls in FormatMessageA/W.
authorAndrew Nguyen <anguyen@codeweavers.com>
Sun, 18 Apr 2010 14:08:42 +0000 (09:08 -0500)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 19 Apr 2010 13:42:42 +0000 (15:42 +0200)
The buffer in question is temporary and will be freed on function
return, so resizing and leaving the enlarged space unused is pointless.

dlls/kernel32/format_msg.c

index c312acddafb32305264f88f7199178fef9e1e84e..f579d21ffc8017f69b5071792e1e66c72870163a 100644 (file)
@@ -565,9 +565,6 @@ DWORD WINAPI FormatMessageA(
         *t='\0';
     }
     talloced = strlen(target)+1;
-    if (nSize && talloced<nSize) {
-        target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,nSize);
-    }
     TRACE("-- %s\n",debugstr_a(target));
     if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
         *((LPVOID*)lpBuffer) = LocalAlloc(LMEM_ZEROINIT,max(nSize, talloced));
@@ -744,8 +741,6 @@ DWORD WINAPI FormatMessageW(
         *t='\0';
     }
     talloced = strlenW(target)+1;
-    if (nSize && talloced<nSize)
-        target = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,target,nSize*sizeof(WCHAR));
     if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
         /* nSize is the MINIMUM size */
         DWORD len = strlenW(target) + 1;