Commit c9e7db92 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

d3dx11: Use CRT memory allocators.

parent 9bc80fbf
...@@ -72,7 +72,7 @@ static HRESULT WINAPI memorydataloader_Destroy(ID3DX11DataLoader *iface) ...@@ -72,7 +72,7 @@ static HRESULT WINAPI memorydataloader_Destroy(ID3DX11DataLoader *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
HeapFree(GetProcessHeap(), 0, loader); free(loader);
return S_OK; return S_OK;
} }
...@@ -100,7 +100,7 @@ static HRESULT WINAPI filedataloader_Load(ID3DX11DataLoader *iface) ...@@ -100,7 +100,7 @@ static HRESULT WINAPI filedataloader_Load(ID3DX11DataLoader *iface)
return D3D11_ERROR_FILE_NOT_FOUND; return D3D11_ERROR_FILE_NOT_FOUND;
size = GetFileSize(file, NULL); size = GetFileSize(file, NULL);
data = HeapAlloc(GetProcessHeap(), 0, size); data = malloc(size);
if (!data) if (!data)
{ {
CloseHandle(file); CloseHandle(file);
...@@ -112,11 +112,11 @@ static HRESULT WINAPI filedataloader_Load(ID3DX11DataLoader *iface) ...@@ -112,11 +112,11 @@ static HRESULT WINAPI filedataloader_Load(ID3DX11DataLoader *iface)
if (!ret) if (!ret)
{ {
ERR("Failed to read file contents.\n"); ERR("Failed to read file contents.\n");
HeapFree(GetProcessHeap(), 0, data); free(data);
return E_FAIL; return E_FAIL;
} }
HeapFree(GetProcessHeap(), 0, loader->data); free(loader->data);
loader->data = data; loader->data = data;
loader->size = size; loader->size = size;
...@@ -144,9 +144,9 @@ static HRESULT WINAPI filedataloader_Destroy(ID3DX11DataLoader *iface) ...@@ -144,9 +144,9 @@ static HRESULT WINAPI filedataloader_Destroy(ID3DX11DataLoader *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
HeapFree(GetProcessHeap(), 0, loader->u.file.path); free(loader->u.file.path);
HeapFree(GetProcessHeap(), 0, loader->data); free(loader->data);
HeapFree(GetProcessHeap(), 0, loader); free(loader);
return S_OK; return S_OK;
} }
...@@ -202,7 +202,7 @@ static HRESULT WINAPI resourcedataloader_Destroy(ID3DX11DataLoader *iface) ...@@ -202,7 +202,7 @@ static HRESULT WINAPI resourcedataloader_Destroy(ID3DX11DataLoader *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
HeapFree(GetProcessHeap(), 0, loader); free(loader);
return S_OK; return S_OK;
} }
...@@ -282,7 +282,7 @@ HRESULT WINAPI D3DX11CreateAsyncMemoryLoader(const void *data, SIZE_T data_size, ...@@ -282,7 +282,7 @@ HRESULT WINAPI D3DX11CreateAsyncMemoryLoader(const void *data, SIZE_T data_size,
if (!data || !loader) if (!data || !loader)
return E_FAIL; return E_FAIL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); object = calloc(1, sizeof(*object));
if (!object) if (!object)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -307,12 +307,12 @@ HRESULT WINAPI D3DX11CreateAsyncFileLoaderA(const char *filename, ID3DX11DataLoa ...@@ -307,12 +307,12 @@ HRESULT WINAPI D3DX11CreateAsyncFileLoaderA(const char *filename, ID3DX11DataLoa
return E_FAIL; return E_FAIL;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
filename_w = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*filename_w)); filename_w = malloc(len * sizeof(*filename_w));
MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len); MultiByteToWideChar(CP_ACP, 0, filename, -1, filename_w, len);
hr = D3DX11CreateAsyncFileLoaderW(filename_w, loader); hr = D3DX11CreateAsyncFileLoaderW(filename_w, loader);
HeapFree(GetProcessHeap(), 0, filename_w); free(filename_w);
return hr; return hr;
} }
...@@ -326,15 +326,15 @@ HRESULT WINAPI D3DX11CreateAsyncFileLoaderW(const WCHAR *filename, ID3DX11DataLo ...@@ -326,15 +326,15 @@ HRESULT WINAPI D3DX11CreateAsyncFileLoaderW(const WCHAR *filename, ID3DX11DataLo
if (!filename || !loader) if (!filename || !loader)
return E_FAIL; return E_FAIL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); object = calloc(1, sizeof(*object));
if (!object) if (!object)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
object->ID3DX11DataLoader_iface.lpVtbl = &filedataloadervtbl; object->ID3DX11DataLoader_iface.lpVtbl = &filedataloadervtbl;
object->u.file.path = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR)); object->u.file.path = malloc((lstrlenW(filename) + 1) * sizeof(WCHAR));
if (!object->u.file.path) if (!object->u.file.path)
{ {
HeapFree(GetProcessHeap(), 0, object); free(object);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
lstrcpyW(object->u.file.path, filename); lstrcpyW(object->u.file.path, filename);
...@@ -356,14 +356,14 @@ HRESULT WINAPI D3DX11CreateAsyncResourceLoaderA(HMODULE module, const char *reso ...@@ -356,14 +356,14 @@ HRESULT WINAPI D3DX11CreateAsyncResourceLoaderA(HMODULE module, const char *reso
if (!loader) if (!loader)
return E_FAIL; return E_FAIL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); object = calloc(1, sizeof(*object));
if (!object) if (!object)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!(rsrc = FindResourceA(module, resource, (const char *)RT_RCDATA))) if (!(rsrc = FindResourceA(module, resource, (const char *)RT_RCDATA)))
{ {
WARN("Failed to find resource.\n"); WARN("Failed to find resource.\n");
HeapFree(GetProcessHeap(), 0, object); free(object);
return D3DX11_ERR_INVALID_DATA; return D3DX11_ERR_INVALID_DATA;
} }
...@@ -388,14 +388,14 @@ HRESULT WINAPI D3DX11CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res ...@@ -388,14 +388,14 @@ HRESULT WINAPI D3DX11CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
if (!loader) if (!loader)
return E_FAIL; return E_FAIL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); object = calloc(1, sizeof(*object));
if (!object) if (!object)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!(rsrc = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA))) if (!(rsrc = FindResourceW(module, resource, (const WCHAR *)RT_RCDATA)))
{ {
WARN("Failed to find resource.\n"); WARN("Failed to find resource.\n");
HeapFree(GetProcessHeap(), 0, object); free(object);
return D3DX11_ERR_INVALID_DATA; return D3DX11_ERR_INVALID_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