Commit 93db373c authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

ole32/tests: Use CRT allocation functions.

parent 3bda0653
......@@ -138,8 +138,8 @@ static ULONG WINAPI EnumFormatImpl_Release(IEnumFORMATETC *iface)
ULONG ref = InterlockedDecrement(&This->ref);
if(!ref) {
HeapFree(GetProcessHeap(), 0, This->fmtetc);
HeapFree(GetProcessHeap(), 0, This);
free(This->fmtetc);
free(This);
}
return ref;
......@@ -207,12 +207,12 @@ static HRESULT EnumFormatImpl_Create(FORMATETC *fmtetc, UINT fmtetc_cnt, IEnumFO
{
EnumFormatImpl *ret;
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(EnumFormatImpl));
ret = malloc(sizeof(EnumFormatImpl));
ret->IEnumFORMATETC_iface.lpVtbl = &VT_EnumFormatImpl;
ret->ref = 1;
ret->cur = 0;
ret->fmtetc_cnt = fmtetc_cnt;
ret->fmtetc = HeapAlloc(GetProcessHeap(), 0, fmtetc_cnt*sizeof(FORMATETC));
ret->fmtetc = malloc(fmtetc_cnt * sizeof(FORMATETC));
memcpy(ret->fmtetc, fmtetc, fmtetc_cnt*sizeof(FORMATETC));
*lplpformatetc = &ret->IEnumFORMATETC_iface;
return S_OK;
......@@ -248,8 +248,8 @@ static ULONG WINAPI DataObjectImpl_Release(IDataObject* iface)
int i;
if(This->text) GlobalFree(This->text);
for(i = 0; i < This->fmtetc_cnt; i++)
HeapFree(GetProcessHeap(), 0, This->fmtetc[i].ptd);
HeapFree(GetProcessHeap(), 0, This->fmtetc);
free(This->fmtetc[i].ptd);
free(This->fmtetc);
if(This->stm) IStream_Release(This->stm);
if(This->stg) IStorage_Release(This->stg);
if(This->hmfp) {
......@@ -258,7 +258,7 @@ static ULONG WINAPI DataObjectImpl_Release(IDataObject* iface)
GlobalUnlock(This->hmfp);
GlobalFree(This->hmfp);
}
HeapFree(GetProcessHeap(), 0, This);
free(This);
}
return ref;
......@@ -417,7 +417,7 @@ static HRESULT DataObjectImpl_CreateFromHGlobal(HGLOBAL text, LPDATAOBJECT *data
{
DataObjectImpl *obj;
obj = HeapAlloc(GetProcessHeap(), 0, sizeof(DataObjectImpl));
obj = malloc(sizeof(DataObjectImpl));
obj->IDataObject_iface.lpVtbl = &VT_DataObjectImpl;
obj->ref = 1;
obj->text = text;
......@@ -426,7 +426,7 @@ static HRESULT DataObjectImpl_CreateFromHGlobal(HGLOBAL text, LPDATAOBJECT *data
obj->hmfp = NULL;
obj->fmtetc_cnt = 1;
obj->fmtetc = HeapAlloc(GetProcessHeap(), 0, obj->fmtetc_cnt*sizeof(FORMATETC));
obj->fmtetc = malloc(obj->fmtetc_cnt * sizeof(FORMATETC));
InitFormatEtc(obj->fmtetc[0], CF_TEXT, TYMED_HGLOBAL);
*dataobj = &obj->IDataObject_iface;
......@@ -451,7 +451,7 @@ static HRESULT DataObjectImpl_CreateComplex(LPDATAOBJECT *lplpdataobj)
ILockBytes *lbs;
DEVMODEW dm;
obj = HeapAlloc(GetProcessHeap(), 0, sizeof(DataObjectImpl));
obj = malloc(sizeof(DataObjectImpl));
obj->IDataObject_iface.lpVtbl = &VT_DataObjectImpl;
obj->ref = 1;
obj->text = GlobalAlloc(GMEM_MOVEABLE, strlen(cmpl_text_data) + 1);
......@@ -468,7 +468,7 @@ static HRESULT DataObjectImpl_CreateComplex(LPDATAOBJECT *lplpdataobj)
obj->fmtetc_cnt = 9;
/* zeroing here since FORMATETC has a hole in it, and it's confusing to have this uninitialised. */
obj->fmtetc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, obj->fmtetc_cnt*sizeof(FORMATETC));
obj->fmtetc = calloc(obj->fmtetc_cnt, sizeof(FORMATETC));
InitFormatEtc(obj->fmtetc[0], CF_TEXT, TYMED_HGLOBAL);
InitFormatEtc(obj->fmtetc[1], cf_stream, TYMED_ISTREAM);
InitFormatEtc(obj->fmtetc[2], cf_storage, TYMED_ISTORAGE);
......@@ -479,7 +479,7 @@ static HRESULT DataObjectImpl_CreateComplex(LPDATAOBJECT *lplpdataobj)
dm.dmSize = sizeof(dm);
dm.dmDriverExtra = 0;
lstrcpyW(dm.dmDeviceName, device_name);
obj->fmtetc[3].ptd = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(DVTARGETDEVICE, tdData) + sizeof(device_name) + dm.dmSize + dm.dmDriverExtra);
obj->fmtetc[3].ptd = malloc(FIELD_OFFSET(DVTARGETDEVICE, tdData) + sizeof(device_name) + dm.dmSize + dm.dmDriverExtra);
obj->fmtetc[3].ptd->tdSize = FIELD_OFFSET(DVTARGETDEVICE, tdData) + sizeof(device_name) + dm.dmSize + dm.dmDriverExtra;
obj->fmtetc[3].ptd->tdDriverNameOffset = FIELD_OFFSET(DVTARGETDEVICE, tdData);
obj->fmtetc[3].ptd->tdDeviceNameOffset = 0;
......@@ -1455,7 +1455,7 @@ static void test_flushed_getdata(void)
dm.dmSize = sizeof(dm);
dm.dmDriverExtra = 0;
lstrcpyW(dm.dmDeviceName, device_name);
fmt.ptd = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(DVTARGETDEVICE, tdData) + sizeof(device_name) + dm.dmSize + dm.dmDriverExtra);
fmt.ptd = malloc(FIELD_OFFSET(DVTARGETDEVICE, tdData) + sizeof(device_name) + dm.dmSize + dm.dmDriverExtra);
fmt.ptd->tdSize = FIELD_OFFSET(DVTARGETDEVICE, tdData) + sizeof(device_name) + dm.dmSize + dm.dmDriverExtra;
fmt.ptd->tdDriverNameOffset = FIELD_OFFSET(DVTARGETDEVICE, tdData);
fmt.ptd->tdDeviceNameOffset = 0;
......@@ -1469,7 +1469,7 @@ static void test_flushed_getdata(void)
ok(med.tymed == TYMED_ISTORAGE, "got %lx\n", med.tymed);
if(SUCCEEDED(hr)) ReleaseStgMedium(&med);
HeapFree(GetProcessHeap(), 0, fmt.ptd);
free(fmt.ptd);
}
/* CF_ENHMETAFILE format */
......
......@@ -2039,7 +2039,7 @@ static ULONG WINAPI Test_CallContext_Release(IUnknown *iface)
Test_CallContext *This = impl_from_IUnknown(iface);
ULONG refs = InterlockedDecrement(&This->refs);
if (!refs)
HeapFree(GetProcessHeap(), 0, This);
free(This);
return refs;
}
......@@ -2065,7 +2065,7 @@ static void test_CoGetCallContext(void)
CoInitialize(NULL);
test_object = HeapAlloc(GetProcessHeap(), 0, sizeof(Test_CallContext));
test_object = malloc(sizeof(Test_CallContext));
test_object->IUnknown_iface.lpVtbl = &TestCallContext_Vtbl;
test_object->refs = 1;
......
......@@ -33,7 +33,6 @@
#include "shobjidl.h"
#include "wine/test.h"
#include "wine/heap.h"
#define DEFINE_EXPECT(func) \
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
......@@ -465,7 +464,7 @@ static ULONG WINAPI RpcStubBuffer_Release(IRpcStubBuffer *iface)
LONG ref = InterlockedDecrement(&This->ref);
if(!ref) {
IRpcStubBuffer_Release(This->buffer);
heap_free(This);
free(This);
}
return ref;
}
......@@ -573,7 +572,7 @@ static ULONG WINAPI RpcProxyBuffer_Release(IRpcProxyBuffer *iface)
LONG ref = InterlockedDecrement(&This->ref);
if(!ref) {
IRpcProxyBuffer_Release(This->buffer);
heap_free(This);
free(This);
}
return ref;
}
......@@ -640,7 +639,7 @@ static HRESULT WINAPI PSFactoryBuffer_CreateProxy(IPSFactoryBuffer *iface, IUnkn
HRESULT hr;
CHECK_EXPECT(CreateProxy);
proxy = heap_alloc(sizeof(*proxy));
proxy = malloc(sizeof(*proxy));
proxy->IRpcProxyBuffer_iface.lpVtbl = &RpcProxyBufferVtbl;
proxy->ref = 1;
......@@ -662,7 +661,7 @@ static HRESULT WINAPI PSFactoryBuffer_CreateStub(IPSFactoryBuffer *iface, REFIID
ok(server == (IUnknown*)&Test_OleClientSite, "unexpected server %p\n", server);
stub = heap_alloc(sizeof(*stub));
stub = malloc(sizeof(*stub));
stub->IRpcStubBuffer_iface.lpVtbl = &RpcStubBufferVtbl;
stub->ref = 1;
......@@ -742,7 +741,7 @@ static DWORD CALLBACK host_object_proc(LPVOID p)
DispatchMessageA(&msg);
}
HeapFree(GetProcessHeap(), 0, data);
free(data);
CoUninitialize();
......@@ -754,7 +753,7 @@ static DWORD start_host_object2(struct host_object_data *object_data, HANDLE *th
DWORD tid = 0;
struct host_object_data *data;
data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
data = malloc(sizeof(*data));
*data = *object_data;
data->marshal_event = CreateEventA(NULL, FALSE, FALSE, NULL);
*thread = CreateThread(NULL, 0, host_object_proc, data, 0, &tid);
......
......@@ -34,7 +34,6 @@
#include "initguid.h"
#include "wine/test.h"
#include "wine/heap.h"
#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
......@@ -405,7 +404,7 @@ static ULONG WINAPI HeapUnknown_Release(IUnknown *iface)
{
HeapUnknown *This = impl_from_IUnknown(iface);
ULONG refs = InterlockedDecrement((LONG*)&This->refs);
if (!refs) HeapFree(GetProcessHeap(), 0, This);
if (!refs) free(This);
return refs;
}
......@@ -616,7 +615,7 @@ Moniker_Release(IMoniker* iface)
ULONG refcount = InterlockedDecrement(&moniker->refcount);
if (!refcount)
heap_free(moniker);
free(moniker);
return refcount;
}
......@@ -880,7 +879,7 @@ static struct test_moniker *create_test_moniker(void)
{
struct test_moniker *obj;
obj = heap_alloc_zero(sizeof(*obj));
obj = calloc(1, sizeof(*obj));
obj->IMoniker_iface.lpVtbl = &MonikerVtbl;
obj->IROTData_iface.lpVtbl = &ROTDataVtbl;
obj->IOleItemContainer_iface.lpVtbl = &test_item_container_vtbl;
......@@ -4391,7 +4390,7 @@ static void test_bind_context(void)
hr = IBindCtx_RegisterObjectParam(pBindCtx, (WCHAR *)wszParamName, NULL);
ok(hr == E_INVALIDARG, "IBindCtx_RegisterObjectParam should have returned E_INVALIDARG instead of 0x%08lx\n", hr);
unknown = HeapAlloc(GetProcessHeap(), 0, sizeof(*unknown));
unknown = malloc(sizeof(*unknown));
unknown->IUnknown_iface.lpVtbl = &HeapUnknown_Vtbl;
unknown->refs = 1;
hr = IBindCtx_RegisterObjectParam(pBindCtx, (WCHAR *)wszParamName, &unknown->IUnknown_iface);
......@@ -4418,7 +4417,7 @@ static void test_bind_context(void)
hr = IBindCtx_RevokeObjectBound(pBindCtx, NULL);
ok(hr == E_INVALIDARG, "IBindCtx_RevokeObjectBound(NULL) should have return E_INVALIDARG instead of 0x%08lx\n", hr);
unknown2 = HeapAlloc(GetProcessHeap(), 0, sizeof(*unknown));
unknown2 = malloc(sizeof(*unknown));
unknown2->IUnknown_iface.lpVtbl = &HeapUnknown_Vtbl;
unknown2->refs = 1;
hr = IBindCtx_RegisterObjectBound(pBindCtx, &unknown2->IUnknown_iface);
......
......@@ -3975,8 +3975,8 @@ static HRESULT stgmedium_cmp(const STGMEDIUM *med1, STGMEDIUM *med2)
datasize2 = GetMetaFileBitsEx(mfpict2->hMF, 0, NULL);
if (datasize1 == datasize2)
{
data1 = HeapAlloc(GetProcessHeap(), 0, datasize1);
data2 = HeapAlloc(GetProcessHeap(), 0, datasize2);
data1 = malloc(datasize1);
data2 = malloc(datasize2);
GetMetaFileBitsEx(mfpict1->hMF, datasize1, data1);
GetMetaFileBitsEx(mfpict2->hMF, datasize2, data2);
}
......@@ -3988,8 +3988,8 @@ static HRESULT stgmedium_cmp(const STGMEDIUM *med1, STGMEDIUM *med2)
datasize2 = GetEnhMetaFileBits(med2->hEnhMetaFile, 0, NULL);
if (datasize1 == datasize2)
{
data1 = HeapAlloc(GetProcessHeap(), 0, datasize1);
data2 = HeapAlloc(GetProcessHeap(), 0, datasize2);
data1 = malloc(datasize1);
data2 = malloc(datasize2);
GetEnhMetaFileBits(med1->hEnhMetaFile, datasize1, data1);
GetEnhMetaFileBits(med2->hEnhMetaFile, datasize2, data2);
}
......@@ -4021,15 +4021,15 @@ static HRESULT stgmedium_cmp(const STGMEDIUM *med1, STGMEDIUM *med2)
}
else if (med1->tymed == TYMED_MFPICT)
{
HeapFree(GetProcessHeap(), 0, data1);
HeapFree(GetProcessHeap(), 0, data2);
free(data1);
free(data2);
GlobalUnlock(med1->hMetaFilePict);
GlobalUnlock(med2->hMetaFilePict);
}
else
{
HeapFree(GetProcessHeap(), 0, data1);
HeapFree(GetProcessHeap(), 0, data2);
free(data1);
free(data2);
}
return S_OK;
......@@ -4125,13 +4125,13 @@ static void get_stgdef(struct storage_def *stg_def, CLIPFORMAT cf, STGMEDIUM *st
if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
{
data_size += sizeof(dib_inf);
data = HeapAlloc(GetProcessHeap(), 0, data_size);
data = malloc(data_size);
memcpy(data, dib_inf, sizeof(dib_inf));
memcpy(data + sizeof(dib_inf), dib_white, sizeof(dib_white));
}
else
{
data = HeapAlloc(GetProcessHeap(), 0, data_size);
data = malloc(data_size);
memcpy(data, dib_white, sizeof(dib_white));
}
stg_def->stream[stm_idx].data = data;
......@@ -4142,14 +4142,14 @@ static void get_stgdef(struct storage_def *stg_def, CLIPFORMAT cf, STGMEDIUM *st
data_size = GetMetaFileBitsEx(mfpict->hMF, 0, NULL);
if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
{
data = HeapAlloc(GetProcessHeap(), 0, data_size + sizeof(mf_rec));
data = malloc(data_size + sizeof(mf_rec));
memcpy(data, mf_rec, sizeof(mf_rec));
GetMetaFileBitsEx(mfpict->hMF, data_size, data + sizeof(mf_rec));
data_size += sizeof(mf_rec);
}
else
{
data = HeapAlloc(GetProcessHeap(), 0, data_size);
data = malloc(data_size);
GetMetaFileBitsEx(mfpict->hMF, data_size, data);
}
GlobalUnlock(stg_med->hMetaFilePict);
......@@ -4160,7 +4160,7 @@ static void get_stgdef(struct storage_def *stg_def, CLIPFORMAT cf, STGMEDIUM *st
if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
{
data_size = GetEnhMetaFileBits(stg_med->hEnhMetaFile, 0, NULL);
data = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) + sizeof(ENHMETAHEADER) + data_size);
data = malloc(sizeof(DWORD) + sizeof(ENHMETAHEADER) + data_size);
*((DWORD *)data) = sizeof(ENHMETAHEADER);
GetEnhMetaFileBits(stg_med->hEnhMetaFile, data_size, data + sizeof(DWORD) + sizeof(ENHMETAHEADER));
memcpy(data + sizeof(DWORD), data + sizeof(DWORD) + sizeof(ENHMETAHEADER), sizeof(ENHMETAHEADER));
......@@ -4170,7 +4170,7 @@ static void get_stgdef(struct storage_def *stg_def, CLIPFORMAT cf, STGMEDIUM *st
{
hdc = GetDC(NULL);
data_size = GetWinMetaFileBits(stg_med->hEnhMetaFile, 0, NULL, MM_ANISOTROPIC, hdc);
data = HeapAlloc(GetProcessHeap(), 0, data_size);
data = malloc(data_size);
GetWinMetaFileBits(stg_med->hEnhMetaFile, data_size, data, MM_ANISOTROPIC, hdc);
ReleaseDC(NULL, hdc);
}
......@@ -4389,7 +4389,7 @@ static void test_data_cache_save_data(void)
IStorage_Release(doc);
IOleCache2_Release(cache);
for (i = 0; i < pdata->num_set; i++)
HeapFree(GetProcessHeap(), 0, (void *)pdata->stg_def.stream[i].data);
free((void *)pdata->stg_def.stream[i].data);
}
}
......@@ -4549,7 +4549,7 @@ static void test_OleCreateStaticFromData(void)
IPersist_Release(persist);
IStorage_Release(storage);
IOleObject_Release(ole_obj);
HeapFree(GetProcessHeap(), 0, (void *)stg_def_dib.stream[2].data);
free((void *)stg_def_dib.stream[2].data);
/* CF_ENHMETAFILE */
hr = CreateILockBytesOnHGlobal(NULL, TRUE, &ilb);
......@@ -4583,7 +4583,7 @@ static void test_OleCreateStaticFromData(void)
IPersist_Release(persist);
IStorage_Release(storage);
IOleObject_Release(ole_obj);
HeapFree(GetProcessHeap(), 0, (void *)stg_def_emf.stream[2].data);
free((void *)stg_def_emf.stream[2].data);
/* CF_TEXT */
hr = CreateILockBytesOnHGlobal(NULL, TRUE, &ilb);
......
......@@ -126,7 +126,7 @@ static ULONG WINAPI UnknownImpl_Release(IUnknown *iface)
InterlockedDecrement(&obj_ref);
trace("server: unknown_Release: %p, ref %lu\n", iface, ref);
if (ref == 0) HeapFree(GetProcessHeap(), 0, This);
if (ref == 0) free(This);
return ref;
}
......@@ -201,7 +201,7 @@ static HRESULT WINAPI ClassFactoryImpl_CreateInstance(IClassFactory *iface,
if (punkouter) return CLASS_E_NOAGGREGATION;
unknown = HeapAlloc(GetProcessHeap(), 0, sizeof(*unknown));
unknown = malloc(sizeof(*unknown));
if (!unknown) return E_OUTOFMEMORY;
unknown->IUnknown_iface.lpVtbl = &UnknownImpl_Vtbl;
......
......@@ -610,7 +610,7 @@ static void test_varianttoproperty(void)
return;
}
own_propvalue = HeapAlloc(GetProcessHeap(), 0, sizeof(SERIALIZEDPROPERTYVALUE) + 20);
own_propvalue = malloc(sizeof(SERIALIZEDPROPERTYVALUE) + 20);
PropVariantInit(&propvar);
......@@ -626,7 +626,7 @@ static void test_varianttoproperty(void)
if (len == 0xdeadbeef)
{
HeapFree(GetProcessHeap(), 0, own_propvalue);
free(own_propvalue);
return;
}
......@@ -680,7 +680,7 @@ static void test_varianttoproperty(void)
SysFreeString(test_string_bstr);
HeapFree(GetProcessHeap(), 0, own_propvalue);
free(own_propvalue);
}
START_TEST(propvariant)
......
......@@ -163,10 +163,10 @@ static HRESULT WINAPI TestLockBytes_SetSize(ILockBytes *iface,
if (This->buffer_size < cb.QuadPart)
{
ULONG new_buffer_size = max(This->buffer_size * 2, cb.QuadPart);
BYTE* new_buffer = HeapAlloc(GetProcessHeap(), 0, new_buffer_size);
BYTE* new_buffer = malloc(new_buffer_size);
if (!new_buffer) return E_OUTOFMEMORY;
memcpy(new_buffer, This->contents, This->size);
HeapFree(GetProcessHeap(), 0, This->contents);
free(This->contents);
This->contents = new_buffer;
}
......@@ -232,7 +232,7 @@ static const ILockBytesVtbl TestLockBytes_Vtbl = {
static void CreateTestLockBytes(TestLockBytes **This)
{
*This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(**This));
*This = calloc(1, sizeof(**This));
if (*This)
{
......@@ -240,7 +240,7 @@ static void CreateTestLockBytes(TestLockBytes **This)
(*This)->ref = 1;
(*This)->size = 0;
(*This)->buffer_size = 1024;
(*This)->contents = HeapAlloc(GetProcessHeap(), 0, (*This)->buffer_size);
(*This)->contents = malloc((*This)->buffer_size);
}
}
......@@ -248,8 +248,8 @@ static void DeleteTestLockBytes(TestLockBytes *This)
{
ok(This->ILockBytes_iface.lpVtbl == &TestLockBytes_Vtbl, "test lock bytes %p deleted with incorrect vtable\n", This);
ok(This->ref == 1, "test lock bytes %p deleted with %li references instead of 1\n", This, This->ref);
HeapFree(GetProcessHeap(), 0, This->contents);
HeapFree(GetProcessHeap(), 0, This);
free(This->contents);
free(This);
}
static void test_hglobal_storage_stat(void)
......
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