mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-21 15:04:10 +00:00
shcore: Use CRT allocation functions.
This commit is contained in:
parent
161f1b7b6f
commit
294be17370
|
@ -33,7 +33,6 @@
|
||||||
#include "shlwapi.h"
|
#include "shlwapi.h"
|
||||||
|
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "wine/heap.h"
|
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shcore);
|
WINE_DEFAULT_DEBUG_CHANNEL(shcore);
|
||||||
|
|
||||||
|
@ -588,8 +587,8 @@ static ULONG WINAPI memstream_Release(IStream *iface)
|
||||||
|
|
||||||
if (!refcount)
|
if (!refcount)
|
||||||
{
|
{
|
||||||
heap_free(stream->u.mem.buffer);
|
free(stream->u.mem.buffer);
|
||||||
heap_free(stream);
|
free(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
return refcount;
|
return refcount;
|
||||||
|
@ -634,7 +633,7 @@ static HRESULT WINAPI memstream_Write(IStream *iface, const void *buff, ULONG bu
|
||||||
|
|
||||||
if (length > stream->u.mem.length)
|
if (length > stream->u.mem.length)
|
||||||
{
|
{
|
||||||
BYTE *buffer = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, stream->u.mem.buffer, length);
|
BYTE *buffer = _recalloc(stream->u.mem.buffer, 1, length);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return STG_E_INSUFFICIENTMEMORY;
|
return STG_E_INSUFFICIENTMEMORY;
|
||||||
|
|
||||||
|
@ -687,7 +686,7 @@ static HRESULT WINAPI memstream_SetSize(IStream *iface, ULARGE_INTEGER new_size)
|
||||||
|
|
||||||
/* we cut off the high part here */
|
/* we cut off the high part here */
|
||||||
length = new_size.u.LowPart;
|
length = new_size.u.LowPart;
|
||||||
buffer = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, stream->u.mem.buffer, length);
|
buffer = _recalloc(stream->u.mem.buffer, 1, length);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return STG_E_INSUFFICIENTMEMORY;
|
return STG_E_INSUFFICIENTMEMORY;
|
||||||
|
|
||||||
|
@ -836,13 +835,13 @@ static struct shstream *shstream_create(const IStreamVtbl *vtbl, const BYTE *dat
|
||||||
if (!data)
|
if (!data)
|
||||||
data_len = 0;
|
data_len = 0;
|
||||||
|
|
||||||
stream = heap_alloc(sizeof(*stream));
|
stream = malloc(sizeof(*stream));
|
||||||
stream->IStream_iface.lpVtbl = vtbl;
|
stream->IStream_iface.lpVtbl = vtbl;
|
||||||
stream->refcount = 1;
|
stream->refcount = 1;
|
||||||
stream->u.mem.buffer = heap_alloc(data_len);
|
stream->u.mem.buffer = malloc(data_len);
|
||||||
if (!stream->u.mem.buffer)
|
if (!stream->u.mem.buffer)
|
||||||
{
|
{
|
||||||
heap_free(stream);
|
free(stream);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memcpy(stream->u.mem.buffer, data, data_len);
|
memcpy(stream->u.mem.buffer, data, data_len);
|
||||||
|
@ -888,8 +887,8 @@ static ULONG WINAPI filestream_Release(IStream *iface)
|
||||||
if (!refcount)
|
if (!refcount)
|
||||||
{
|
{
|
||||||
CloseHandle(stream->u.file.handle);
|
CloseHandle(stream->u.file.handle);
|
||||||
heap_free(stream->u.file.path);
|
free(stream->u.file.path);
|
||||||
heap_free(stream);
|
free(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
return refcount;
|
return refcount;
|
||||||
|
@ -1157,14 +1156,14 @@ HRESULT WINAPI SHCreateStreamOnFileEx(const WCHAR *path, DWORD mode, DWORD attri
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
return HRESULT_FROM_WIN32(GetLastError());
|
return HRESULT_FROM_WIN32(GetLastError());
|
||||||
|
|
||||||
stream = heap_alloc(sizeof(*stream));
|
stream = malloc(sizeof(*stream));
|
||||||
stream->IStream_iface.lpVtbl = &filestreamvtbl;
|
stream->IStream_iface.lpVtbl = &filestreamvtbl;
|
||||||
stream->refcount = 1;
|
stream->refcount = 1;
|
||||||
stream->u.file.handle = hFile;
|
stream->u.file.handle = hFile;
|
||||||
stream->u.file.mode = mode;
|
stream->u.file.mode = mode;
|
||||||
|
|
||||||
len = lstrlenW(path);
|
len = lstrlenW(path);
|
||||||
stream->u.file.path = heap_alloc((len + 1) * sizeof(WCHAR));
|
stream->u.file.path = malloc((len + 1) * sizeof(WCHAR));
|
||||||
memcpy(stream->u.file.path, path, (len + 1) * sizeof(WCHAR));
|
memcpy(stream->u.file.path, path, (len + 1) * sizeof(WCHAR));
|
||||||
|
|
||||||
*ret = &stream->IStream_iface;
|
*ret = &stream->IStream_iface;
|
||||||
|
@ -1203,13 +1202,13 @@ HRESULT WINAPI SHCreateStreamOnFileA(const char *path, DWORD mode, IStream **str
|
||||||
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
|
return HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND);
|
||||||
|
|
||||||
len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
|
len = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
|
||||||
pathW = heap_alloc(len * sizeof(WCHAR));
|
pathW = malloc(len * sizeof(WCHAR));
|
||||||
if (!pathW)
|
if (!pathW)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, len);
|
MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, len);
|
||||||
hr = SHCreateStreamOnFileW(pathW, mode, stream);
|
hr = SHCreateStreamOnFileW(pathW, mode, stream);
|
||||||
heap_free(pathW);
|
free(pathW);
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -1233,8 +1232,8 @@ static ULONG WINAPI regstream_Release(IStream *iface)
|
||||||
RegCloseKey(stream->u.mem.hkey);
|
RegCloseKey(stream->u.mem.hkey);
|
||||||
}
|
}
|
||||||
CoTaskMemFree(stream->u.mem.valuename);
|
CoTaskMemFree(stream->u.mem.valuename);
|
||||||
heap_free(stream->u.mem.buffer);
|
free(stream->u.mem.buffer);
|
||||||
heap_free(stream);
|
free(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
return refcount;
|
return refcount;
|
||||||
|
@ -1284,16 +1283,16 @@ IStream * WINAPI SHOpenRegStream2W(HKEY hKey, const WCHAR *subkey, const WCHAR *
|
||||||
ret = RegQueryValueExW(hStrKey, value, 0, 0, 0, &length);
|
ret = RegQueryValueExW(hStrKey, value, 0, 0, 0, &length);
|
||||||
if (ret == ERROR_SUCCESS && length)
|
if (ret == ERROR_SUCCESS && length)
|
||||||
{
|
{
|
||||||
buff = heap_alloc(length);
|
buff = malloc(length);
|
||||||
RegQueryValueExW(hStrKey, value, 0, 0, buff, &length);
|
RegQueryValueExW(hStrKey, value, 0, 0, buff, &length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!length)
|
if (!length)
|
||||||
buff = heap_alloc(length);
|
buff = malloc(length);
|
||||||
|
|
||||||
stream = shstream_create(®streamvtbl, buff, length);
|
stream = shstream_create(®streamvtbl, buff, length);
|
||||||
heap_free(buff);
|
free(buff);
|
||||||
if (stream)
|
if (stream)
|
||||||
{
|
{
|
||||||
stream->u.mem.hkey = hStrKey;
|
stream->u.mem.hkey = hStrKey;
|
||||||
|
@ -1458,7 +1457,7 @@ static ULONG WINAPI threadref_Release(IUnknown *iface)
|
||||||
TRACE("%p, refcount %ld.\n", threadref, refcount);
|
TRACE("%p, refcount %ld.\n", threadref, refcount);
|
||||||
|
|
||||||
if (!refcount)
|
if (!refcount)
|
||||||
heap_free(threadref);
|
free(threadref);
|
||||||
|
|
||||||
return refcount;
|
return refcount;
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1483,7 @@ HRESULT WINAPI SHCreateThreadRef(LONG *refcount, IUnknown **out)
|
||||||
|
|
||||||
*out = NULL;
|
*out = NULL;
|
||||||
|
|
||||||
threadref = heap_alloc(sizeof(*threadref));
|
threadref = malloc(sizeof(*threadref));
|
||||||
if (!threadref)
|
if (!threadref)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
threadref->IUnknown_iface.lpVtbl = &threadrefvtbl;
|
threadref->IUnknown_iface.lpVtbl = &threadrefvtbl;
|
||||||
|
@ -1993,10 +1992,10 @@ DWORD WINAPI SHCopyKeyW(HKEY hkey_src, const WCHAR *subkey, HKEY hkey_dst, DWORD
|
||||||
max_key_len = max(max_key_len, max_value_len);
|
max_key_len = max(max_key_len, max_value_len);
|
||||||
|
|
||||||
if (max_key_len++ > MAX_PATH - 1)
|
if (max_key_len++ > MAX_PATH - 1)
|
||||||
ptr_name = heap_alloc(max_key_len * sizeof(WCHAR));
|
ptr_name = malloc(max_key_len * sizeof(WCHAR));
|
||||||
|
|
||||||
if (max_data_len > sizeof(buff))
|
if (max_data_len > sizeof(buff))
|
||||||
ptr = heap_alloc(max_data_len);
|
ptr = malloc(max_data_len);
|
||||||
|
|
||||||
if (!ptr_name || !ptr)
|
if (!ptr_name || !ptr)
|
||||||
ret = ERROR_NOT_ENOUGH_MEMORY;
|
ret = ERROR_NOT_ENOUGH_MEMORY;
|
||||||
|
@ -2040,9 +2039,9 @@ DWORD WINAPI SHCopyKeyW(HKEY hkey_src, const WCHAR *subkey, HKEY hkey_dst, DWORD
|
||||||
|
|
||||||
/* Free buffers if allocated */
|
/* Free buffers if allocated */
|
||||||
if (ptr_name != name)
|
if (ptr_name != name)
|
||||||
heap_free(ptr_name);
|
free(ptr_name);
|
||||||
if (ptr != buff)
|
if (ptr != buff)
|
||||||
heap_free(ptr);
|
free(ptr);
|
||||||
|
|
||||||
if (subkey && hkey_src)
|
if (subkey && hkey_src)
|
||||||
RegCloseKey(hkey_src);
|
RegCloseKey(hkey_src);
|
||||||
|
@ -2118,20 +2117,20 @@ DWORD WINAPI SHQueryValueExW(HKEY hkey, const WCHAR *name, DWORD *reserved, DWOR
|
||||||
if (!buff || ret == ERROR_MORE_DATA)
|
if (!buff || ret == ERROR_MORE_DATA)
|
||||||
{
|
{
|
||||||
length = data_len;
|
length = data_len;
|
||||||
value = heap_alloc(length);
|
value = malloc(length);
|
||||||
RegQueryValueExW(hkey, name, reserved, NULL, (BYTE *)value, &length);
|
RegQueryValueExW(hkey, name, reserved, NULL, (BYTE *)value, &length);
|
||||||
length = ExpandEnvironmentStringsW(value, NULL, 0);
|
length = ExpandEnvironmentStringsW(value, NULL, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = (lstrlenW(buff) + 1) * sizeof(WCHAR);
|
length = (lstrlenW(buff) + 1) * sizeof(WCHAR);
|
||||||
value = heap_alloc(length);
|
value = malloc(length);
|
||||||
memcpy(value, buff, length);
|
memcpy(value, buff, length);
|
||||||
length = ExpandEnvironmentStringsW(value, buff, *buff_len / sizeof(WCHAR));
|
length = ExpandEnvironmentStringsW(value, buff, *buff_len / sizeof(WCHAR));
|
||||||
if (length > *buff_len) ret = ERROR_MORE_DATA;
|
if (length > *buff_len) ret = ERROR_MORE_DATA;
|
||||||
}
|
}
|
||||||
data_len = max(data_len, length);
|
data_len = max(data_len, length);
|
||||||
heap_free(value);
|
free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
|
@ -2166,20 +2165,20 @@ DWORD WINAPI SHQueryValueExA(HKEY hkey, const char *name, DWORD *reserved, DWORD
|
||||||
if (!buff || ret == ERROR_MORE_DATA)
|
if (!buff || ret == ERROR_MORE_DATA)
|
||||||
{
|
{
|
||||||
length = data_len;
|
length = data_len;
|
||||||
value = heap_alloc(length);
|
value = malloc(length);
|
||||||
RegQueryValueExA(hkey, name, reserved, NULL, (BYTE *)value, &length);
|
RegQueryValueExA(hkey, name, reserved, NULL, (BYTE *)value, &length);
|
||||||
length = ExpandEnvironmentStringsA(value, NULL, 0);
|
length = ExpandEnvironmentStringsA(value, NULL, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = strlen(buff) + 1;
|
length = strlen(buff) + 1;
|
||||||
value = heap_alloc(length);
|
value = malloc(length);
|
||||||
memcpy(value, buff, length);
|
memcpy(value, buff, length);
|
||||||
length = ExpandEnvironmentStringsA(value, buff, *buff_len);
|
length = ExpandEnvironmentStringsA(value, buff, *buff_len);
|
||||||
if (length > *buff_len) ret = ERROR_MORE_DATA;
|
if (length > *buff_len) ret = ERROR_MORE_DATA;
|
||||||
}
|
}
|
||||||
data_len = max(data_len, length);
|
data_len = max(data_len, length);
|
||||||
heap_free(value);
|
free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
|
|
Loading…
Reference in a new issue