Commit dbf222f3 authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

Use LMEM_ flags for LocalAlloc(), not GMEM_ (GlobalAlloc).

parent e3fe6892
...@@ -324,7 +324,7 @@ DWORD WINAPI FormatMessageA( ...@@ -324,7 +324,7 @@ DWORD WINAPI FormatMessageA(
} }
TRACE("-- %s\n",debugstr_a(target)); TRACE("-- %s\n",debugstr_a(target));
if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) { if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
*((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(GMEM_ZEROINIT,max(nSize, talloced)); *((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(LMEM_ZEROINIT,max(nSize, talloced));
memcpy(*(LPSTR*)lpBuffer,target,talloced); memcpy(*(LPSTR*)lpBuffer,target,talloced);
} else { } else {
lstrcpynA(lpBuffer,target,nSize); lstrcpynA(lpBuffer,target,nSize);
...@@ -537,7 +537,7 @@ DWORD WINAPI FormatMessageW( ...@@ -537,7 +537,7 @@ DWORD WINAPI FormatMessageW(
if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) { if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) {
/* nSize is the MINIMUM size */ /* nSize is the MINIMUM size */
DWORD len = strlenW(target) + 1; DWORD len = strlenW(target) + 1;
*((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(GMEM_ZEROINIT,len*sizeof(WCHAR)); *((LPVOID*)lpBuffer) = (LPVOID)LocalAlloc(LMEM_ZEROINIT,len*sizeof(WCHAR));
strcpyW(*(LPWSTR*)lpBuffer, target); strcpyW(*(LPWSTR*)lpBuffer, target);
} }
else lstrcpynW(lpBuffer, target, nSize); else lstrcpynW(lpBuffer, target, nSize);
......
...@@ -63,17 +63,17 @@ START_TEST(heap) ...@@ -63,17 +63,17 @@ START_TEST(heap)
ok(gbl == NULL, "global realloc allocated memory\n"); ok(gbl == NULL, "global realloc allocated memory\n");
/* Local*() functions */ /* Local*() functions */
gbl = LocalAlloc(GMEM_MOVEABLE, 0); gbl = LocalAlloc(LMEM_MOVEABLE, 0);
ok(gbl != NULL, "local memory not allocated for size 0\n"); ok(gbl != NULL, "local memory not allocated for size 0\n");
gbl = LocalReAlloc(gbl, 10, GMEM_MOVEABLE); gbl = LocalReAlloc(gbl, 10, LMEM_MOVEABLE);
ok(gbl != NULL, "Can't realloc local memory\n"); ok(gbl != NULL, "Can't realloc local memory\n");
size = LocalSize(gbl); size = LocalSize(gbl);
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size); ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
todo_wine todo_wine
{ {
gbl = LocalReAlloc(gbl, 0, GMEM_MOVEABLE); gbl = LocalReAlloc(gbl, 0, LMEM_MOVEABLE);
ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n"); ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n");
} }
...@@ -83,7 +83,7 @@ START_TEST(heap) ...@@ -83,7 +83,7 @@ START_TEST(heap)
size = LocalSize(gbl); size = LocalSize(gbl);
ok(size == 0, "Memory should have been freed, size=%ld\n", size); ok(size == 0, "Memory should have been freed, size=%ld\n", size);
gbl = LocalReAlloc(0, 10, GMEM_MOVEABLE); gbl = LocalReAlloc(0, 10, LMEM_MOVEABLE);
ok(gbl == NULL, "local realloc allocated memory\n"); ok(gbl == NULL, "local realloc allocated memory\n");
} }
...@@ -112,7 +112,7 @@ static LPVOID WINAPI IMAPIMalloc_fnAlloc(LPMALLOC iface, DWORD cb) ...@@ -112,7 +112,7 @@ static LPVOID WINAPI IMAPIMalloc_fnAlloc(LPMALLOC iface, DWORD cb)
{ {
TRACE("(%p)->(%ld)\n", iface, cb); TRACE("(%p)->(%ld)\n", iface, cb);
return LocalAlloc(GMEM_FIXED, cb); return LocalAlloc(LMEM_FIXED, cb);
} }
/************************************************************************** /**************************************************************************
...@@ -123,10 +123,10 @@ static LPVOID WINAPI IMAPIMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb) ...@@ -123,10 +123,10 @@ static LPVOID WINAPI IMAPIMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb)
TRACE("(%p)->(%p, %ld)\n", iface, pv, cb); TRACE("(%p)->(%p, %ld)\n", iface, pv, cb);
if (!pv) if (!pv)
return LocalAlloc(GMEM_FIXED, cb); return LocalAlloc(LMEM_FIXED, cb);
if (cb) if (cb)
return LocalReAlloc((HANDLE) pv, cb, GMEM_MOVEABLE); return LocalReAlloc((HANDLE) pv, cb, LMEM_MOVEABLE);
LocalFree((HANDLE) pv); LocalFree((HANDLE) pv);
return NULL; return NULL;
......
...@@ -77,8 +77,8 @@ static int SetSpyedBlockTableLength ( int NewLength ) ...@@ -77,8 +77,8 @@ static int SetSpyedBlockTableLength ( int NewLength )
{ {
LPVOID *NewSpyedBlocks; LPVOID *NewSpyedBlocks;
if (!Malloc32.SpyedBlocks) NewSpyedBlocks = LocalAlloc(GMEM_ZEROINIT, NewLength * sizeof(PVOID)); if (!Malloc32.SpyedBlocks) NewSpyedBlocks = LocalAlloc(LMEM_ZEROINIT, NewLength * sizeof(PVOID));
else NewSpyedBlocks = LocalReAlloc(Malloc32.SpyedBlocks, NewLength * sizeof(PVOID), GMEM_ZEROINIT); else NewSpyedBlocks = LocalReAlloc(Malloc32.SpyedBlocks, NewLength * sizeof(PVOID), LMEM_ZEROINIT);
if (NewSpyedBlocks) { if (NewSpyedBlocks) {
Malloc32.SpyedBlocks = NewSpyedBlocks; Malloc32.SpyedBlocks = NewSpyedBlocks;
Malloc32.SpyedBlockTableLength = NewLength; Malloc32.SpyedBlockTableLength = NewLength;
......
...@@ -124,7 +124,7 @@ HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOI ...@@ -124,7 +124,7 @@ HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOI
if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
sf = (ICPanelImpl *) LocalAlloc(GMEM_ZEROINIT, sizeof(ICPanelImpl)); sf = (ICPanelImpl *) LocalAlloc(LMEM_ZEROINIT, sizeof(ICPanelImpl));
if (!sf) if (!sf)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -71,7 +71,7 @@ HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, ...@@ -71,7 +71,7 @@ HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid,
if (pUnkOuter) if (pUnkOuter)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
dth = (IDropTargetHelperImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IDropTargetHelperImpl)); dth = (IDropTargetHelperImpl *) LocalAlloc (LMEM_ZEROINIT, sizeof (IDropTargetHelperImpl));
if (!dth) return E_OUTOFMEMORY; if (!dth) return E_OUTOFMEMORY;
dth->ref = 0; dth->ref = 0;
......
...@@ -1093,7 +1093,7 @@ HRESULT WINAPI IShellLink_Constructor ( ...@@ -1093,7 +1093,7 @@ HRESULT WINAPI IShellLink_Constructor (
*ppv = NULL; *ppv = NULL;
if(pUnkOuter) return CLASS_E_NOAGGREGATION; if(pUnkOuter) return CLASS_E_NOAGGREGATION;
sl = (IShellLinkImpl *) LocalAlloc(GMEM_ZEROINIT,sizeof(IShellLinkImpl)); sl = (IShellLinkImpl *) LocalAlloc(LMEM_ZEROINIT,sizeof(IShellLinkImpl));
if (!sl) return E_OUTOFMEMORY; if (!sl) return E_OUTOFMEMORY;
sl->ref = 1; sl->ref = 1;
......
...@@ -318,7 +318,7 @@ static LPVOID WINAPI IShellMalloc_fnAlloc(LPMALLOC iface, DWORD cb) ...@@ -318,7 +318,7 @@ static LPVOID WINAPI IShellMalloc_fnAlloc(LPMALLOC iface, DWORD cb)
{ {
LPVOID addr; LPVOID addr;
addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb); addr = (LPVOID) LocalAlloc(LMEM_ZEROINIT, cb);
TRACE("(%p,%ld);\n",addr,cb); TRACE("(%p,%ld);\n",addr,cb);
return addr; return addr;
} }
...@@ -332,14 +332,14 @@ static LPVOID WINAPI IShellMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb) ...@@ -332,14 +332,14 @@ static LPVOID WINAPI IShellMalloc_fnRealloc(LPMALLOC iface, LPVOID pv, DWORD cb)
if (pv) { if (pv) {
if (cb) { if (cb) {
addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, GMEM_ZEROINIT | GMEM_MOVEABLE); addr = (LPVOID) LocalReAlloc((HANDLE) pv, cb, LMEM_ZEROINIT | LMEM_MOVEABLE);
} else { } else {
LocalFree((HANDLE) pv); LocalFree((HANDLE) pv);
addr = NULL; addr = NULL;
} }
} else { } else {
if (cb) { if (cb) {
addr = (LPVOID) LocalAlloc(GMEM_ZEROINIT, cb); addr = (LPVOID) LocalAlloc(LMEM_ZEROINIT, cb);
} else { } else {
addr = NULL; addr = NULL;
} }
......
...@@ -1506,7 +1506,7 @@ HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1) ...@@ -1506,7 +1506,7 @@ HRESULT WINAPI SHELL32_256(LPDWORD lpdw0, LPDWORD lpdw1)
ret = E_INVALIDARG; ret = E_INVALIDARG;
else else
{ {
LPVOID lpdata = 0;/*LocalAlloc(GMEM_ZEROINIT, 0x4E4);*/ LPVOID lpdata = 0;/*LocalAlloc(LMEM_ZEROINIT, 0x4E4);*/
if (!lpdata) if (!lpdata)
ret = E_OUTOFMEMORY; ret = E_OUTOFMEMORY;
......
...@@ -837,7 +837,7 @@ HRESULT WINAPI ISF_Desktop_Constructor ( ...@@ -837,7 +837,7 @@ HRESULT WINAPI ISF_Desktop_Constructor (
if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE )) if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE ))
return E_UNEXPECTED; return E_UNEXPECTED;
sf = LocalAlloc( GMEM_ZEROINIT, sizeof (IGenericSFImpl) ); sf = LocalAlloc( LMEM_ZEROINIT, sizeof (IGenericSFImpl) );
if (!sf) if (!sf)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -233,7 +233,7 @@ IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv) ...@@ -233,7 +233,7 @@ IFSFolder_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown)) if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl)); sf = (IGenericSFImpl *) LocalAlloc (LMEM_ZEROINIT, sizeof (IGenericSFImpl));
if (!sf) if (!sf)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -108,7 +108,7 @@ HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LP ...@@ -108,7 +108,7 @@ HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LP
if (pUnkOuter) if (pUnkOuter)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
sf = LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl)); sf = LocalAlloc (LMEM_ZEROINIT, sizeof (IGenericSFImpl));
if (!sf) if (!sf)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -1340,7 +1340,7 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue, ...@@ -1340,7 +1340,7 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue,
char cNull = '\0'; char cNull = '\0';
nBytesToAlloc = (!pvData || (dwRet == ERROR_MORE_DATA)) ? dwUnExpDataLen : *pcbData; nBytesToAlloc = (!pvData || (dwRet == ERROR_MORE_DATA)) ? dwUnExpDataLen : *pcbData;
szData = (LPSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc); szData = (LPSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc);
RegQueryValueExA (hKey, lpszValue, lpReserved, NULL, (LPBYTE)szData, &nBytesToAlloc); RegQueryValueExA (hKey, lpszValue, lpReserved, NULL, (LPBYTE)szData, &nBytesToAlloc);
dwExpDataLen = ExpandEnvironmentStringsA(szData, &cNull, 1); dwExpDataLen = ExpandEnvironmentStringsA(szData, &cNull, 1);
dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen); dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
...@@ -1349,7 +1349,7 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue, ...@@ -1349,7 +1349,7 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue,
else else
{ {
nBytesToAlloc = (lstrlenA(pvData)+1) * sizeof (CHAR); nBytesToAlloc = (lstrlenA(pvData)+1) * sizeof (CHAR);
szData = (LPSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc ); szData = (LPSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc );
lstrcpyA(szData, pvData); lstrcpyA(szData, pvData);
dwExpDataLen = ExpandEnvironmentStringsA(szData, pvData, *pcbData / sizeof(CHAR)); dwExpDataLen = ExpandEnvironmentStringsA(szData, pvData, *pcbData / sizeof(CHAR));
if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA; if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA;
...@@ -1401,7 +1401,7 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, ...@@ -1401,7 +1401,7 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue,
WCHAR cNull = '\0'; WCHAR cNull = '\0';
nBytesToAlloc = (!pvData || (dwRet == ERROR_MORE_DATA)) ? dwUnExpDataLen : *pcbData; nBytesToAlloc = (!pvData || (dwRet == ERROR_MORE_DATA)) ? dwUnExpDataLen : *pcbData;
szData = (LPWSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc); szData = (LPWSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc);
RegQueryValueExW (hKey, lpszValue, lpReserved, NULL, (LPBYTE)szData, &nBytesToAlloc); RegQueryValueExW (hKey, lpszValue, lpReserved, NULL, (LPBYTE)szData, &nBytesToAlloc);
dwExpDataLen = ExpandEnvironmentStringsW(szData, &cNull, 1); dwExpDataLen = ExpandEnvironmentStringsW(szData, &cNull, 1);
dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen); dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
...@@ -1410,7 +1410,7 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, ...@@ -1410,7 +1410,7 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue,
else else
{ {
nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR); nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR);
szData = (LPWSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc ); szData = (LPWSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc );
lstrcpyW(szData, pvData); lstrcpyW(szData, pvData);
dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, *pcbData/sizeof(WCHAR) ); dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, *pcbData/sizeof(WCHAR) );
if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA; if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment