Commit 9bc80fbf authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

d3dx10: Use CRT memory allocators.

parent acf815fd
......@@ -73,7 +73,7 @@ static HRESULT WINAPI memorydataloader_Destroy(ID3DX10DataLoader *iface)
TRACE("iface %p.\n", iface);
HeapFree(GetProcessHeap(), 0, loader);
free(loader);
return S_OK;
}
......@@ -101,7 +101,7 @@ static HRESULT WINAPI filedataloader_Load(ID3DX10DataLoader *iface)
return D3D10_ERROR_FILE_NOT_FOUND;
size = GetFileSize(file, NULL);
data = HeapAlloc(GetProcessHeap(), 0, size);
data = malloc(size);
if (!data)
{
CloseHandle(file);
......@@ -113,11 +113,11 @@ static HRESULT WINAPI filedataloader_Load(ID3DX10DataLoader *iface)
if (!ret)
{
WARN("Failed to read file contents.\n");
HeapFree(GetProcessHeap(), 0, data);
free(data);
return E_FAIL;
}
HeapFree(GetProcessHeap(), 0, loader->data);
free(loader->data);
loader->data = data;
loader->size = size;
......@@ -145,9 +145,9 @@ static HRESULT WINAPI filedataloader_Destroy(ID3DX10DataLoader *iface)
TRACE("iface %p.\n", iface);
HeapFree(GetProcessHeap(), 0, loader->u.file.path);
HeapFree(GetProcessHeap(), 0, loader->data);
HeapFree(GetProcessHeap(), 0, loader);
free(loader->u.file.path);
free(loader->data);
free(loader);
return S_OK;
}
......@@ -203,7 +203,7 @@ static HRESULT WINAPI resourcedataloader_Destroy(ID3DX10DataLoader *iface)
TRACE("iface %p.\n", iface);
HeapFree(GetProcessHeap(), 0, loader);
free(loader);
return S_OK;
}
......@@ -266,7 +266,7 @@ HRESULT WINAPI D3DX10CreateAsyncMemoryLoader(const void *data, SIZE_T data_size,
if (!data || !loader)
return E_FAIL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
......@@ -291,12 +291,12 @@ HRESULT WINAPI D3DX10CreateAsyncFileLoaderA(const char *filename, ID3DX10DataLoa
return E_FAIL;
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);
hr = D3DX10CreateAsyncFileLoaderW(filename_w, loader);
HeapFree(GetProcessHeap(), 0, filename_w);
free(filename_w);
return hr;
}
......@@ -310,15 +310,15 @@ HRESULT WINAPI D3DX10CreateAsyncFileLoaderW(const WCHAR *filename, ID3DX10DataLo
if (!filename || !loader)
return E_FAIL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
object->ID3DX10DataLoader_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)
{
HeapFree(GetProcessHeap(), 0, object);
free(object);
return E_OUTOFMEMORY;
}
lstrcpyW(object->u.file.path, filename);
......@@ -340,7 +340,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE module, const char *reso
if (!loader)
return E_FAIL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
......@@ -349,7 +349,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE module, const char *reso
if (!rsrc)
{
WARN("Failed to find resource.\n");
HeapFree(GetProcessHeap(), 0, object);
free(object);
return D3DX10_ERR_INVALID_DATA;
}
......@@ -374,7 +374,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
if (!loader)
return E_FAIL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
object = calloc(1, sizeof(*object));
if (!object)
return E_OUTOFMEMORY;
......@@ -383,7 +383,7 @@ HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *res
if (!rsrc)
{
WARN("Failed to find resource.\n");
HeapFree(GetProcessHeap(), 0, object);
free(object);
return D3DX10_ERR_INVALID_DATA;
}
......
......@@ -18,7 +18,6 @@
*/
#include "wine/debug.h"
#include "wine/heap.h"
#define COBJMACROS
......@@ -113,13 +112,13 @@ HRESULT WINAPI D3DX10CreateEffectFromFileA(const char *filename, const D3D10_SHA
return E_INVALIDARG;
len = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
if (!(filenameW = heap_alloc(len * sizeof(*filenameW))))
if (!(filenameW = malloc(len * sizeof(*filenameW))))
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, len);
hr = D3DX10CreateEffectFromFileW(filenameW, defines, include, profile, shader_flags,
effect_flags, device, effect_pool, pump, effect, errors, hresult);
heap_free(filenameW);
free(filenameW);
return hr;
}
......@@ -198,13 +197,13 @@ HRESULT WINAPI D3DX10CreateEffectFromResourceW(HMODULE module, const WCHAR *reso
if (filenameW)
{
len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
if (!(filename = heap_alloc(len)))
if (!(filename = malloc(len)))
return E_OUTOFMEMORY;
WideCharToMultiByte(CP_ACP, 0, filenameW, -1, filename, len, NULL, NULL);
}
hr = D3DX10CreateEffectFromMemory(data, size, filename, defines, include, profile,
shader_flags, effect_flags, device, effect_pool, pump, effect, errors, hresult);
heap_free(filename);
free(filename);
return hr;
}
......@@ -21,7 +21,6 @@
#include "d3dx10.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
......@@ -82,7 +81,7 @@ static ULONG WINAPI d3dx_font_Release(ID3DX10Font *iface)
DeleteObject(font->hfont);
DeleteDC(font->hdc);
ID3D10Device_Release(font->device);
heap_free(font);
free(font);
}
return refcount;
}
......@@ -179,14 +178,14 @@ static HRESULT WINAPI d3dx_font_PreloadCharacters(ID3DX10Font *iface, UINT first
return S_OK;
count = last - first + 1;
indices = heap_alloc(count * sizeof(*indices));
indices = malloc(count * sizeof(*indices));
if (!indices)
return E_OUTOFMEMORY;
chars = heap_alloc(count * sizeof(*chars));
chars = malloc(count * sizeof(*chars));
if (!chars)
{
heap_free(indices);
free(indices);
return E_OUTOFMEMORY;
}
......@@ -208,8 +207,8 @@ static HRESULT WINAPI d3dx_font_PreloadCharacters(ID3DX10Font *iface, UINT first
}
ID3DX10Font_PreloadGlyphs(iface, start, end);
heap_free(chars);
heap_free(indices);
free(chars);
free(indices);
return S_OK;
}
......@@ -237,14 +236,14 @@ static HRESULT WINAPI d3dx_font_PreloadTextA(ID3DX10Font *iface, const char *str
countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0);
if (!(wstr = heap_alloc(countW * sizeof(*wstr))))
if (!(wstr = malloc(countW * sizeof(*wstr))))
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
hr = ID3DX10Font_PreloadTextW(iface, wstr, count < 0 ? countW - 1 : countW);
heap_free(wstr);
free(wstr);
return hr;
}
......@@ -266,7 +265,7 @@ static HRESULT WINAPI d3dx_font_PreloadTextW(ID3DX10Font *iface, const WCHAR *st
if (count < 0)
count = lstrlenW(string);
indices = heap_alloc(count * sizeof(*indices));
indices = malloc(count * sizeof(*indices));
if (!indices)
return E_OUTOFMEMORY;
......@@ -275,7 +274,7 @@ static HRESULT WINAPI d3dx_font_PreloadTextW(ID3DX10Font *iface, const WCHAR *st
for (i = 0; i < count; ++i)
ID3DX10Font_PreloadGlyphs(iface, indices[i], indices[i]);
heap_free(indices);
free(indices);
return S_OK;
}
......@@ -296,7 +295,7 @@ static INT WINAPI d3dx_font_DrawTextA(ID3DX10Font *iface, ID3DX10Sprite *sprite,
if (!(countW = MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, NULL, 0)))
return 0;
if (!(wstr = heap_alloc_zero(countW * sizeof(*wstr))))
if (!(wstr = calloc(countW, sizeof(*wstr))))
return 0;
MultiByteToWideChar(CP_ACP, 0, string, count < 0 ? -1 : count, wstr, countW);
......@@ -304,7 +303,7 @@ static INT WINAPI d3dx_font_DrawTextA(ID3DX10Font *iface, ID3DX10Sprite *sprite,
ret = ID3DX10Font_DrawTextW(iface, sprite, wstr, count < 0 ? countW - 1 : countW,
rect, format, color);
heap_free(wstr);
free(wstr);
return ret;
}
......@@ -430,13 +429,13 @@ HRESULT WINAPI D3DX10CreateFontIndirectW(ID3D10Device *device, const D3DX10_FONT
*font = NULL;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->hdc = CreateCompatibleDC(NULL);
if (!object->hdc)
{
heap_free(object);
free(object);
return E_FAIL;
}
......@@ -445,7 +444,7 @@ HRESULT WINAPI D3DX10CreateFontIndirectW(ID3D10Device *device, const D3DX10_FONT
if (!object->hfont)
{
DeleteDC(object->hdc);
heap_free(object);
free(object);
return E_FAIL;
}
SelectObject(object->hdc, object->hfont);
......
......@@ -21,7 +21,6 @@
#include "d3dx10.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
......@@ -72,7 +71,7 @@ static ULONG STDMETHODCALLTYPE d3dx10_mesh_Release(ID3DX10Mesh *iface)
TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
if (!refcount)
heap_free(mesh);
free(mesh);
return refcount;
}
......@@ -366,7 +365,7 @@ HRESULT WINAPI D3DX10CreateMesh(ID3D10Device *device, const D3D10_INPUT_ELEMENT_
*mesh = NULL;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->ID3DX10Mesh_iface.lpVtbl = &d3dx10_mesh_vtbl;
......
......@@ -21,7 +21,6 @@
#include "d3dx10.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
......@@ -79,7 +78,7 @@ static ULONG WINAPI d3dx10_sprite_Release(ID3DX10Sprite *iface)
if (!refcount)
{
ID3D10Device_Release(sprite->device);
heap_free(sprite);
free(sprite);
}
return refcount;
......@@ -209,7 +208,7 @@ HRESULT WINAPI D3DX10CreateSprite(ID3D10Device *device, UINT size, ID3DX10Sprite
*sprite = NULL;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
object->ID3DX10Sprite_iface.lpVtbl = &d3dx10_sprite_vtbl;
......
......@@ -17,7 +17,6 @@
*/
#include "wine/debug.h"
#include "wine/heap.h"
#define COBJMACROS
......@@ -313,7 +312,7 @@ static HRESULT load_file(const WCHAR *filename, void **buffer, DWORD *size)
goto done;
}
*buffer = heap_alloc(*size);
*buffer = malloc(*size);
if (!*buffer)
{
hr = E_OUTOFMEMORY;
......@@ -335,7 +334,7 @@ static HRESULT load_file(const WCHAR *filename, void **buffer, DWORD *size)
done:
if (FAILED(hr))
{
heap_free(*buffer);
free(*buffer);
*buffer = NULL;
}
if (file != INVALID_HANDLE_VALUE)
......@@ -375,14 +374,14 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileA(const char *src_file, ID3DX10ThreadPu
if (!str_len)
return HRESULT_FROM_WIN32(GetLastError());
buffer = heap_alloc(str_len * sizeof(*buffer));
buffer = malloc(str_len * sizeof(*buffer));
if (!buffer)
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len);
hr = D3DX10GetImageInfoFromFileW(buffer, pump, info, result);
heap_free(buffer);
free(buffer);
return hr;
}
......@@ -404,7 +403,7 @@ HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadP
hr = D3DX10GetImageInfoFromMemory(buffer, size, pump, info, result);
heap_free(buffer);
free(buffer);
return hr;
}
......@@ -589,13 +588,13 @@ HRESULT WINAPI D3DX10CreateTextureFromFileA(ID3D10Device *device, const char *sr
if (!(str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0)))
return HRESULT_FROM_WIN32(GetLastError());
if (!(buffer = heap_alloc(str_len * sizeof(*buffer))))
if (!(buffer = malloc(str_len * sizeof(*buffer))))
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len);
hr = D3DX10CreateTextureFromFileW(device, buffer, load_info, pump, texture, hresult);
heap_free(buffer);
free(buffer);
return hr;
}
......@@ -618,7 +617,7 @@ HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *s
hr = D3DX10CreateTextureFromMemory(device, buffer, size, load_info, pump, texture, hresult);
heap_free(buffer);
free(buffer);
return hr;
}
......@@ -740,7 +739,7 @@ HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *s
stride = (width * get_bpp_from_format(img_info.Format) + 7) / 8;
frame_size = stride * height;
if (!(buffer = heap_alloc(frame_size)))
if (!(buffer = malloc(frame_size)))
{
hr = E_FAIL;
goto end;
......@@ -813,7 +812,7 @@ end:
IWICFormatConverter_Release(converter);
if (dds_frame)
IWICDdsFrameDecode_Release(dds_frame);
heap_free(buffer);
free(buffer);
if (frame)
IWICBitmapFrameDecode_Release(frame);
if (decoder)
......
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