Commit 909f7aa7 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Use CRT allocation functions.

parent 1a8d6f55
...@@ -633,14 +633,16 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run) ...@@ -633,14 +633,16 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run)
int pair_count = 0; int pair_count = 0;
int i; int i;
open_stack = heap_alloc(sizeof(WCHAR) * iso_run->length); open_stack = malloc(sizeof(WCHAR) * iso_run->length);
stack_index = heap_alloc(sizeof(int) * iso_run->length); stack_index = malloc(sizeof(int) * iso_run->length);
for (i = 0; i < iso_run->length; i++) { for (i = 0; i < iso_run->length; i++) {
unsigned short ubv = get_table_entry(bidi_bracket_table, iso_run->item[i].ch); unsigned short ubv = get_table_entry(bidi_bracket_table, iso_run->item[i].ch);
if (ubv) { if (ubv)
if (!out) { {
out = heap_alloc(sizeof(BracketPair)); if (!out)
{
out = malloc(sizeof(BracketPair));
out[0].start = -1; out[0].start = -1;
} }
...@@ -663,7 +665,7 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run) ...@@ -663,7 +665,7 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run)
out[pair_count].start = stack_index[j]; out[pair_count].start = stack_index[j];
out[pair_count].end = i; out[pair_count].end = i;
pair_count++; pair_count++;
out = heap_realloc(out, sizeof(BracketPair) * (pair_count+1)); out = realloc(out, sizeof(BracketPair) * (pair_count+1));
out[pair_count].start = -1; out[pair_count].start = -1;
stack_top = j+1; stack_top = j+1;
break; break;
...@@ -672,15 +674,16 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run) ...@@ -672,15 +674,16 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run)
} }
} }
} }
if (pair_count == 0) { if (pair_count == 0)
heap_free(out); {
free(out);
out = NULL; out = NULL;
} }
else if (pair_count > 1) else if (pair_count > 1)
qsort(out, pair_count, sizeof(BracketPair), bracketpair_compr); qsort(out, pair_count, sizeof(BracketPair), bracketpair_compr);
heap_free(open_stack); free(open_stack);
heap_free(stack_index); free(stack_index);
return out; return out;
} }
...@@ -774,7 +777,7 @@ static void bidi_resolve_neutrals(IsolatedRun *run) ...@@ -774,7 +777,7 @@ static void bidi_resolve_neutrals(IsolatedRun *run)
i++; i++;
p = &pairs[i]; p = &pairs[i];
} }
heap_free(pairs); free(pairs);
} }
/* N1 */ /* N1 */
...@@ -920,8 +923,7 @@ static HRESULT bidi_compute_isolating_runs_set(UINT8 baselevel, UINT8 *classes, ...@@ -920,8 +923,7 @@ static HRESULT bidi_compute_isolating_runs_set(UINT8 baselevel, UINT8 *classes,
HRESULT hr = S_OK; HRESULT hr = S_OK;
Run *runs; Run *runs;
runs = heap_calloc(count, sizeof(*runs)); if (!(runs = calloc(count, sizeof(*runs))))
if (!runs)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
list_init(set); list_init(set);
...@@ -949,8 +951,8 @@ static HRESULT bidi_compute_isolating_runs_set(UINT8 baselevel, UINT8 *classes, ...@@ -949,8 +951,8 @@ static HRESULT bidi_compute_isolating_runs_set(UINT8 baselevel, UINT8 *classes,
int type_fence, real_end; int type_fence, real_end;
int j; int j;
current_isolated = heap_alloc(sizeof(IsolatedRun) + sizeof(RunChar)*count); if (!(current_isolated = malloc(sizeof(IsolatedRun) + sizeof(RunChar)*count)))
if (!current_isolated) { {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
break; break;
} }
...@@ -1040,7 +1042,7 @@ search: ...@@ -1040,7 +1042,7 @@ search:
i++; i++;
} }
heap_free(runs); free(runs);
return hr; return hr;
} }
...@@ -1053,8 +1055,7 @@ HRESULT bidi_computelevels(const WCHAR *string, UINT32 count, UINT8 baselevel, U ...@@ -1053,8 +1055,7 @@ HRESULT bidi_computelevels(const WCHAR *string, UINT32 count, UINT8 baselevel, U
TRACE("%s, %u\n", debugstr_wn(string, count), count); TRACE("%s, %u\n", debugstr_wn(string, count), count);
chartype = heap_alloc(count*sizeof(*chartype)); if (!(chartype = malloc(count * sizeof(*chartype))))
if (!chartype)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
bidi_classify(string, chartype, count); bidi_classify(string, chartype, count);
...@@ -1081,7 +1082,7 @@ HRESULT bidi_computelevels(const WCHAR *string, UINT32 count, UINT8 baselevel, U ...@@ -1081,7 +1082,7 @@ HRESULT bidi_computelevels(const WCHAR *string, UINT32 count, UINT8 baselevel, U
if (TRACE_ON(bidi)) iso_dump_types("after neutrals", iso_run); if (TRACE_ON(bidi)) iso_dump_types("after neutrals", iso_run);
list_remove(&iso_run->entry); list_remove(&iso_run->entry);
heap_free(iso_run); free(iso_run);
} }
if (TRACE_ON(bidi)) bidi_dump_types("before implicit", chartype, 0, count); if (TRACE_ON(bidi)) bidi_dump_types("before implicit", chartype, 0, count);
...@@ -1091,6 +1092,6 @@ HRESULT bidi_computelevels(const WCHAR *string, UINT32 count, UINT8 baselevel, U ...@@ -1091,6 +1092,6 @@ HRESULT bidi_computelevels(const WCHAR *string, UINT32 count, UINT8 baselevel, U
bidi_resolve_resolved(baselevel, chartype, levels, 0, count-1); bidi_resolve_resolved(baselevel, chartype, levels, 0, count-1);
done: done:
heap_free(chartype); free(chartype);
return hr; return hr;
} }
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "winternl.h" #include "winternl.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h" #include "wine/list.h"
#define MS_GSUB_TAG DWRITE_MAKE_OPENTYPE_TAG('G','S','U','B') #define MS_GSUB_TAG DWRITE_MAKE_OPENTYPE_TAG('G','S','U','B')
...@@ -34,29 +33,13 @@ static const DWRITE_MATRIX identity = ...@@ -34,29 +33,13 @@ static const DWRITE_MATRIX identity =
0.0f, 0.0f 0.0f, 0.0f
}; };
static inline LPWSTR heap_strdupW(const WCHAR *str)
{
LPWSTR ret = NULL;
if(str) {
DWORD size;
size = (lstrlenW(str) + 1)*sizeof(WCHAR);
ret = heap_alloc(size);
if(ret)
memcpy(ret, str, size);
}
return ret;
}
static inline LPWSTR heap_strdupnW(const WCHAR *str, UINT32 len) static inline LPWSTR heap_strdupnW(const WCHAR *str, UINT32 len)
{ {
WCHAR *ret = NULL; WCHAR *ret = NULL;
if (len) if (len)
{ {
ret = heap_alloc((len+1)*sizeof(WCHAR)); ret = malloc((len+1)*sizeof(WCHAR));
if(ret) if(ret)
{ {
memcpy(ret, str, len*sizeof(WCHAR)); memcpy(ret, str, len*sizeof(WCHAR));
...@@ -97,10 +80,7 @@ static inline BOOL dwrite_array_reserve(void **elements, size_t *capacity, size_ ...@@ -97,10 +80,7 @@ static inline BOOL dwrite_array_reserve(void **elements, size_t *capacity, size_
if (new_capacity < count) if (new_capacity < count)
new_capacity = max_capacity; new_capacity = max_capacity;
if (!*elements) new_elements = realloc(*elements, new_capacity * size);
new_elements = RtlAllocateHeap(GetProcessHeap(), 0, new_capacity * size);
else
new_elements = RtlReAllocateHeap(GetProcessHeap(), 0, *elements, new_capacity * size);
if (!new_elements) if (!new_elements)
return FALSE; return FALSE;
......
...@@ -267,7 +267,7 @@ static ULONG WINAPI rendertarget_Release(IDWriteBitmapRenderTarget1 *iface) ...@@ -267,7 +267,7 @@ static ULONG WINAPI rendertarget_Release(IDWriteBitmapRenderTarget1 *iface)
{ {
IDWriteFactory7_Release(target->factory); IDWriteFactory7_Release(target->factory);
DeleteDC(target->hdc); DeleteDC(target->hdc);
heap_free(target); free(target);
} }
return refcount; return refcount;
...@@ -460,8 +460,8 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac ...@@ -460,8 +460,8 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac
color = colorref_to_pixel_888(color); color = colorref_to_pixel_888(color);
if (texturetype == DWRITE_TEXTURE_CLEARTYPE_3x1) if (texturetype == DWRITE_TEXTURE_CLEARTYPE_3x1)
size *= 3; size *= 3;
bitmap = heap_alloc_zero(size); if (!(bitmap = calloc(1, size)))
if (!bitmap) { {
IDWriteGlyphRunAnalysis_Release(analysis); IDWriteGlyphRunAnalysis_Release(analysis);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -477,7 +477,7 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac ...@@ -477,7 +477,7 @@ static HRESULT WINAPI rendertarget_DrawGlyphRun(IDWriteBitmapRenderTarget1 *ifac
if (bbox_ret) *bbox_ret = target_rect; if (bbox_ret) *bbox_ret = target_rect;
} }
heap_free(bitmap); free(bitmap);
} }
IDWriteGlyphRunAnalysis_Release(analysis); IDWriteGlyphRunAnalysis_Release(analysis);
...@@ -605,8 +605,8 @@ static HRESULT create_rendertarget(IDWriteFactory7 *factory, HDC hdc, UINT32 wid ...@@ -605,8 +605,8 @@ static HRESULT create_rendertarget(IDWriteFactory7 *factory, HDC hdc, UINT32 wid
*ret = NULL; *ret = NULL;
target = heap_alloc(sizeof(struct rendertarget)); if (!(target = malloc(sizeof(*target))))
if (!target) return E_OUTOFMEMORY; return E_OUTOFMEMORY;
target->IDWriteBitmapRenderTarget1_iface.lpVtbl = &rendertargetvtbl; target->IDWriteBitmapRenderTarget1_iface.lpVtbl = &rendertargetvtbl;
target->ID2D1SimplifiedGeometrySink_iface.lpVtbl = &rendertargetsinkvtbl; target->ID2D1SimplifiedGeometrySink_iface.lpVtbl = &rendertargetsinkvtbl;
...@@ -671,7 +671,7 @@ static ULONG WINAPI gdiinterop_Release(IDWriteGdiInterop1 *iface) ...@@ -671,7 +671,7 @@ static ULONG WINAPI gdiinterop_Release(IDWriteGdiInterop1 *iface)
{ {
IDWriteFactory7_UnregisterFontFileLoader(interop->factory, &interop->IDWriteFontFileLoader_iface); IDWriteFactory7_UnregisterFontFileLoader(interop->factory, &interop->IDWriteFontFileLoader_iface);
factory_detach_gdiinterop(interop->factory, iface); factory_detach_gdiinterop(interop->factory, iface);
heap_free(interop); free(interop);
} }
return refcount; return refcount;
...@@ -795,12 +795,12 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface ...@@ -795,12 +795,12 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface
return E_FAIL; return E_FAIL;
} }
fileinfo = heap_alloc(needed); if (!(fileinfo = malloc(needed)))
if (!fileinfo)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!GetFontFileInfo(info.instance_id, 0, fileinfo, needed, &needed)) { if (!GetFontFileInfo(info.instance_id, 0, fileinfo, needed, &needed))
heap_free(fileinfo); {
free(fileinfo);
return E_FAIL; return E_FAIL;
} }
...@@ -810,7 +810,7 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface ...@@ -810,7 +810,7 @@ static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop1 *iface
hr = IDWriteFactory7_CreateCustomFontFileReference(interop->factory, &info.instance_id, hr = IDWriteFactory7_CreateCustomFontFileReference(interop->factory, &info.instance_id,
sizeof(info.instance_id), &interop->IDWriteFontFileLoader_iface, &file); sizeof(info.instance_id), &interop->IDWriteFontFileLoader_iface, &file);
heap_free(fileinfo); free(fileinfo);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
...@@ -962,7 +962,7 @@ static ULONG WINAPI memresourcestream_Release(IDWriteFontFileStream *iface) ...@@ -962,7 +962,7 @@ static ULONG WINAPI memresourcestream_Release(IDWriteFontFileStream *iface)
TRACE("%p, refcount %d.\n", iface, refcount); TRACE("%p, refcount %d.\n", iface, refcount);
if (!refcount) if (!refcount)
heap_free(stream); free(stream);
return refcount; return refcount;
} }
...@@ -986,7 +986,7 @@ static HRESULT WINAPI memresourcestream_ReadFileFragment(IDWriteFontFileStream * ...@@ -986,7 +986,7 @@ static HRESULT WINAPI memresourcestream_ReadFileFragment(IDWriteFontFileStream *
if ((offset >= fileinfo.size.QuadPart - 1) || (fragment_size > fileinfo.size.QuadPart - offset)) if ((offset >= fileinfo.size.QuadPart - 1) || (fragment_size > fileinfo.size.QuadPart - offset))
return E_INVALIDARG; return E_INVALIDARG;
if (!(fragment = heap_alloc(fragment_size))) if (!(fragment = malloc(fragment_size)))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!GetFontFileData(stream->key, 0, offset, fragment, fragment_size)) if (!GetFontFileData(stream->key, 0, offset, fragment, fragment_size))
...@@ -1000,7 +1000,7 @@ static void WINAPI memresourcestream_ReleaseFileFragment(IDWriteFontFileStream * ...@@ -1000,7 +1000,7 @@ static void WINAPI memresourcestream_ReleaseFileFragment(IDWriteFontFileStream *
{ {
TRACE("%p, %p.\n", iface, fragment_context); TRACE("%p, %p.\n", iface, fragment_context);
heap_free(fragment_context); free(fragment_context);
} }
static HRESULT WINAPI memresourcestream_GetFileSize(IDWriteFontFileStream *iface, UINT64 *size) static HRESULT WINAPI memresourcestream_GetFileSize(IDWriteFontFileStream *iface, UINT64 *size)
...@@ -1073,7 +1073,7 @@ static HRESULT WINAPI memresourceloader_CreateStreamFromKey(IDWriteFontFileLoade ...@@ -1073,7 +1073,7 @@ static HRESULT WINAPI memresourceloader_CreateStreamFromKey(IDWriteFontFileLoade
if (!key || key_size != sizeof(DWORD)) if (!key || key_size != sizeof(DWORD))
return E_INVALIDARG; return E_INVALIDARG;
if (!(stream = heap_alloc(sizeof(*stream)))) if (!(stream = malloc(sizeof(*stream))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
stream->IDWriteFontFileStream_iface.lpVtbl = &memresourcestreamvtbl; stream->IDWriteFontFileStream_iface.lpVtbl = &memresourcestreamvtbl;
...@@ -1099,7 +1099,7 @@ HRESULT create_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 **ret) ...@@ -1099,7 +1099,7 @@ HRESULT create_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 **ret)
*ret = NULL; *ret = NULL;
if (!(interop = heap_alloc(sizeof(*interop)))) if (!(interop = malloc(sizeof(*interop))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
interop->IDWriteGdiInterop1_iface.lpVtbl = &gdiinteropvtbl; interop->IDWriteGdiInterop1_iface.lpVtbl = &gdiinteropvtbl;
......
...@@ -113,7 +113,7 @@ static ULONG WINAPI renderingparams_Release(IDWriteRenderingParams3 *iface) ...@@ -113,7 +113,7 @@ static ULONG WINAPI renderingparams_Release(IDWriteRenderingParams3 *iface)
TRACE("%p, refcount %d.\n", iface, refcount); TRACE("%p, refcount %d.\n", iface, refcount);
if (!refcount) if (!refcount)
heap_free(params); free(params);
return refcount; return refcount;
} }
...@@ -235,7 +235,7 @@ static HRESULT create_renderingparams(float gamma, float contrast, float graysca ...@@ -235,7 +235,7 @@ static HRESULT create_renderingparams(float gamma, float contrast, float graysca
if ((UINT32)gridfit > DWRITE_GRID_FIT_MODE_ENABLED || (UINT32)geometry > DWRITE_PIXEL_GEOMETRY_BGR) if ((UINT32)gridfit > DWRITE_GRID_FIT_MODE_ENABLED || (UINT32)geometry > DWRITE_PIXEL_GEOMETRY_BGR)
return E_INVALIDARG; return E_INVALIDARG;
if (!(object = heap_alloc(sizeof(*object)))) if (!(object = malloc(sizeof(*object))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
object->IDWriteRenderingParams3_iface.lpVtbl = &renderingparamsvtbl; object->IDWriteRenderingParams3_iface.lpVtbl = &renderingparamsvtbl;
...@@ -312,12 +312,12 @@ static ULONG WINAPI localizedstrings_Release(IDWriteLocalizedStrings *iface) ...@@ -312,12 +312,12 @@ static ULONG WINAPI localizedstrings_Release(IDWriteLocalizedStrings *iface)
{ {
for (i = 0; i < strings->count; ++i) for (i = 0; i < strings->count; ++i)
{ {
heap_free(strings->data[i].locale); free(strings->data[i].locale);
heap_free(strings->data[i].string); free(strings->data[i].string);
} }
heap_free(strings->data); free(strings->data);
heap_free(strings); free(strings);
} }
return refcount; return refcount;
...@@ -449,8 +449,7 @@ HRESULT create_localizedstrings(IDWriteLocalizedStrings **strings) ...@@ -449,8 +449,7 @@ HRESULT create_localizedstrings(IDWriteLocalizedStrings **strings)
*strings = NULL; *strings = NULL;
object = heap_alloc_zero(sizeof(*object)); if (!(object = calloc(1, sizeof(*object))))
if (!object)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
object->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl; object->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
...@@ -477,12 +476,12 @@ HRESULT add_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *locale, ...@@ -477,12 +476,12 @@ HRESULT add_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *locale,
if (!dwrite_array_reserve((void **)&strings->data, &strings->size, strings->count + 1, sizeof(*strings->data))) if (!dwrite_array_reserve((void **)&strings->data, &strings->size, strings->count + 1, sizeof(*strings->data)))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
strings->data[count].locale = heap_strdupW(locale); strings->data[count].locale = wcsdup(locale);
strings->data[count].string = heap_strdupW(string); strings->data[count].string = wcsdup(string);
if (!strings->data[count].locale || !strings->data[count].string) if (!strings->data[count].locale || !strings->data[count].string)
{ {
heap_free(strings->data[count].locale); free(strings->data[count].locale);
heap_free(strings->data[count].string); free(strings->data[count].string);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
wcslwr(strings->data[count].locale); wcslwr(strings->data[count].locale);
...@@ -503,14 +502,13 @@ HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedS ...@@ -503,14 +502,13 @@ HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedS
return S_FALSE; return S_FALSE;
strings = impl_from_IDWriteLocalizedStrings(iface); strings = impl_from_IDWriteLocalizedStrings(iface);
strings_clone = heap_alloc_zero(sizeof(*strings_clone)); if (!(strings_clone = calloc(1, sizeof(*strings_clone))))
if (!strings_clone)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if (!dwrite_array_reserve((void **)&strings_clone->data, &strings_clone->size, strings->count, if (!dwrite_array_reserve((void **)&strings_clone->data, &strings_clone->size, strings->count,
sizeof(*strings_clone->data))) sizeof(*strings_clone->data)))
{ {
heap_free(strings_clone); free(strings_clone);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
...@@ -520,8 +518,8 @@ HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedS ...@@ -520,8 +518,8 @@ HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedS
for (i = 0; i < strings_clone->count; ++i) for (i = 0; i < strings_clone->count; ++i)
{ {
strings_clone->data[i].locale = heap_strdupW(strings->data[i].locale); strings_clone->data[i].locale = wcsdup(strings->data[i].locale);
strings_clone->data[i].string = heap_strdupW(strings->data[i].string); strings_clone->data[i].string = wcsdup(strings->data[i].string);
} }
*ret = &strings_clone->IDWriteLocalizedStrings_iface; *ret = &strings_clone->IDWriteLocalizedStrings_iface;
...@@ -538,8 +536,8 @@ void set_en_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *string) ...@@ -538,8 +536,8 @@ void set_en_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *string)
{ {
if (!wcsicmp(strings->data[i].locale, L"en-US")) if (!wcsicmp(strings->data[i].locale, L"en-US"))
{ {
heap_free(strings->data[i].string); free(strings->data[i].string);
strings->data[i].string = heap_strdupW(string); strings->data[i].string = wcsdup(string);
break; break;
} }
} }
...@@ -622,7 +620,7 @@ static void release_fontface_cache(struct list *fontfaces) ...@@ -622,7 +620,7 @@ static void release_fontface_cache(struct list *fontfaces)
LIST_FOR_EACH_ENTRY_SAFE(fontface, fontface2, fontfaces, struct fontfacecached, entry) { LIST_FOR_EACH_ENTRY_SAFE(fontface, fontface2, fontfaces, struct fontfacecached, entry) {
list_remove(&fontface->entry); list_remove(&fontface->entry);
fontface_detach_from_cache(fontface->fontface); fontface_detach_from_cache(fontface->fontface);
heap_free(fontface); free(fontface);
} }
} }
...@@ -631,7 +629,7 @@ static void release_fileloader(struct fileloader *fileloader) ...@@ -631,7 +629,7 @@ static void release_fileloader(struct fileloader *fileloader)
list_remove(&fileloader->entry); list_remove(&fileloader->entry);
release_fontface_cache(&fileloader->fontfaces); release_fontface_cache(&fileloader->fontfaces);
IDWriteFontFileLoader_Release(fileloader->loader); IDWriteFontFileLoader_Release(fileloader->loader);
heap_free(fileloader); free(fileloader);
} }
static void release_dwritefactory(struct dwritefactory *factory) static void release_dwritefactory(struct dwritefactory *factory)
...@@ -646,7 +644,7 @@ static void release_dwritefactory(struct dwritefactory *factory) ...@@ -646,7 +644,7 @@ static void release_dwritefactory(struct dwritefactory *factory)
LIST_FOR_EACH_ENTRY_SAFE(loader, loader2, &factory->collection_loaders, struct collectionloader, entry) { LIST_FOR_EACH_ENTRY_SAFE(loader, loader2, &factory->collection_loaders, struct collectionloader, entry) {
list_remove(&loader->entry); list_remove(&loader->entry);
IDWriteFontCollectionLoader_Release(loader->loader); IDWriteFontCollectionLoader_Release(loader->loader);
heap_free(loader); free(loader);
} }
LIST_FOR_EACH_ENTRY_SAFE(fileloader, fileloader2, &factory->file_loaders, struct fileloader, entry) LIST_FOR_EACH_ENTRY_SAFE(fileloader, fileloader2, &factory->file_loaders, struct fileloader, entry)
...@@ -661,7 +659,7 @@ static void release_dwritefactory(struct dwritefactory *factory) ...@@ -661,7 +659,7 @@ static void release_dwritefactory(struct dwritefactory *factory)
factory->cs.DebugInfo->Spare[0] = 0; factory->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&factory->cs); DeleteCriticalSection(&factory->cs);
heap_free(factory); free(factory);
} }
static void release_shared_factory(IDWriteFactory7 *iface) static void release_shared_factory(IDWriteFactory7 *iface)
...@@ -820,8 +818,7 @@ static HRESULT WINAPI dwritefactory_RegisterFontCollectionLoader(IDWriteFactory7 ...@@ -820,8 +818,7 @@ static HRESULT WINAPI dwritefactory_RegisterFontCollectionLoader(IDWriteFactory7
if (factory_get_collection_loader(factory, loader)) if (factory_get_collection_loader(factory, loader))
return DWRITE_E_ALREADYREGISTERED; return DWRITE_E_ALREADYREGISTERED;
entry = heap_alloc(sizeof(*entry)); if (!(entry = malloc(sizeof(*entry))))
if (!entry)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
entry->loader = loader; entry->loader = loader;
...@@ -848,7 +845,7 @@ static HRESULT WINAPI dwritefactory_UnregisterFontCollectionLoader(IDWriteFactor ...@@ -848,7 +845,7 @@ static HRESULT WINAPI dwritefactory_UnregisterFontCollectionLoader(IDWriteFactor
IDWriteFontCollectionLoader_Release(found->loader); IDWriteFontCollectionLoader_Release(found->loader);
list_remove(&found->entry); list_remove(&found->entry);
heap_free(found); free(found);
return S_OK; return S_OK;
} }
...@@ -871,7 +868,7 @@ static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory7 *ifa ...@@ -871,7 +868,7 @@ static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory7 *ifa
return hr; return hr;
hr = create_font_file(factory->localfontfileloader, key, key_size, font_file); hr = create_font_file(factory->localfontfileloader, key, key_size, font_file);
heap_free(key); free(key);
return hr; return hr;
} }
...@@ -986,8 +983,7 @@ struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *iface, struct lis ...@@ -986,8 +983,7 @@ struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *iface, struct lis
struct fontfacecached *cached; struct fontfacecached *cached;
/* new cache entry */ /* new cache entry */
cached = heap_alloc(sizeof(*cached)); if (!(cached = malloc(sizeof(*cached))))
if (!cached)
return NULL; return NULL;
cached->fontface = fontface; cached->fontface = fontface;
...@@ -1128,8 +1124,7 @@ static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory7 *ifac ...@@ -1128,8 +1124,7 @@ static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory7 *ifac
if (factory_get_file_loader(factory, loader)) if (factory_get_file_loader(factory, loader))
return DWRITE_E_ALREADYREGISTERED; return DWRITE_E_ALREADYREGISTERED;
entry = heap_alloc(sizeof(*entry)); if (!(entry = malloc(sizeof(*entry))))
if (!entry)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
entry->loader = loader; entry->loader = loader;
...@@ -1525,17 +1520,17 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count) ...@@ -1525,17 +1520,17 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count)
} }
value_size = MAX_PATH * sizeof(*value); value_size = MAX_PATH * sizeof(*value);
value = heap_alloc(value_size); value = malloc(value_size);
max_name_count = MAX_PATH; max_name_count = MAX_PATH;
name = heap_alloc(max_name_count * sizeof(*name)); name = malloc(max_name_count * sizeof(*name));
for (;;) for (;;)
{ {
if (!value) if (!value)
{ {
value_size = MAX_PATH * sizeof(*value); value_size = MAX_PATH * sizeof(*value);
value = heap_alloc(value_size); value = malloc(value_size);
} }
do do
...@@ -1549,15 +1544,15 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count) ...@@ -1549,15 +1544,15 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count)
if (name_count >= max_name_count) if (name_count >= max_name_count)
{ {
max_name_count *= 2; max_name_count *= 2;
heap_free(name); free(name);
name = heap_alloc(max_name_count * sizeof(*name)); name = malloc(max_name_count * sizeof(*name));
} }
if (data_size > value_size - sizeof(*value)) if (data_size > value_size - sizeof(*value))
{ {
heap_free(value); free(value);
value_size = max(data_size + sizeof(*value), value_size * 2); value_size = max(data_size + sizeof(*value), value_size * 2);
value = heap_alloc(value_size); value = malloc(value_size);
} }
} }
} while (r == ERROR_MORE_DATA); } while (r == ERROR_MORE_DATA);
...@@ -1574,12 +1569,12 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count) ...@@ -1574,12 +1569,12 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count)
{ {
WCHAR *ptrW; WCHAR *ptrW;
ptrW = heap_alloc((MAX_PATH + wcslen(value)) * sizeof(WCHAR)); ptrW = malloc((MAX_PATH + wcslen(value)) * sizeof(WCHAR));
GetWindowsDirectoryW(ptrW, MAX_PATH); GetWindowsDirectoryW(ptrW, MAX_PATH);
wcscat(ptrW, L"\\fonts\\"); wcscat(ptrW, L"\\fonts\\");
wcscat(ptrW, value); wcscat(ptrW, value);
heap_free(value); free(value);
value = ptrW; value = ptrW;
} }
...@@ -1590,8 +1585,8 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count) ...@@ -1590,8 +1585,8 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count)
index++; index++;
} }
heap_free(value); free(value);
heap_free(name); free(name);
*ret = paths; *ret = paths;
*ret_count = count; *ret_count = count;
...@@ -1636,8 +1631,8 @@ static HRESULT create_system_fontset(IDWriteFactory7 *factory, REFIID riid, void ...@@ -1636,8 +1631,8 @@ static HRESULT create_system_fontset(IDWriteFactory7 *factory, REFIID riid, void
} }
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
heap_free(paths[i]); free(paths[i]);
heap_free(paths); free(paths);
} }
if (SUCCEEDED(hr = IDWriteFontSetBuilder2_CreateFontSet(builder, &fontset))) if (SUCCEEDED(hr = IDWriteFontSetBuilder2_CreateFontSet(builder, &fontset)))
...@@ -2075,8 +2070,8 @@ HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnkno ...@@ -2075,8 +2070,8 @@ HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnkno
if (type == DWRITE_FACTORY_TYPE_SHARED && shared_factory) if (type == DWRITE_FACTORY_TYPE_SHARED && shared_factory)
return IDWriteFactory7_QueryInterface(shared_factory, riid, (void**)ret); return IDWriteFactory7_QueryInterface(shared_factory, riid, (void**)ret);
factory = heap_alloc(sizeof(struct dwritefactory)); if (!(factory = calloc(1, sizeof(*factory))))
if (!factory) return E_OUTOFMEMORY; return E_OUTOFMEMORY;
init_dwritefactory(factory, type); init_dwritefactory(factory, type);
......
...@@ -2332,7 +2332,7 @@ static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, uns ...@@ -2332,7 +2332,7 @@ static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, uns
if (codepage) if (codepage)
{ {
DWORD len = MultiByteToWideChar(codepage, 0, name, length, NULL, 0); DWORD len = MultiByteToWideChar(codepage, 0, name, length, NULL, 0);
name_string = heap_alloc(sizeof(WCHAR) * (len+1)); name_string = malloc(sizeof(WCHAR) * (len+1));
MultiByteToWideChar(codepage, 0, name, length, name_string, len); MultiByteToWideChar(codepage, 0, name, length, name_string, len);
name_string[len] = 0; name_string[len] = 0;
} }
...@@ -2346,7 +2346,7 @@ static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, uns ...@@ -2346,7 +2346,7 @@ static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, uns
TRACE("string %s for locale %s found\n", debugstr_w(name_string), debugstr_w(locale)); TRACE("string %s for locale %s found\n", debugstr_w(name_string), debugstr_w(locale));
add_localizedstring(strings, locale, name_string); add_localizedstring(strings, locale, name_string);
heap_free(name_string); free(name_string);
ret = !wcscmp(locale, L"en-US"); ret = !wcscmp(locale, L"en-US");
} }
...@@ -2507,9 +2507,9 @@ static HRESULT opentype_get_font_strings_from_meta(const struct file_stream_desc ...@@ -2507,9 +2507,9 @@ static HRESULT opentype_get_font_strings_from_meta(const struct file_stream_desc
if ((data = table_read_ensure(&meta, GET_BE_DWORD(maps[i].offset), length))) if ((data = table_read_ensure(&meta, GET_BE_DWORD(maps[i].offset), length)))
{ {
WCHAR *ptrW = heap_alloc((length + 1) * sizeof(WCHAR)), *ctx, *token; WCHAR *ptrW, *ctx, *token;
if (!ptrW) if (!(ptrW = malloc((length + 1) * sizeof(WCHAR))))
{ {
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
goto end; goto end;
...@@ -2528,7 +2528,7 @@ static HRESULT opentype_get_font_strings_from_meta(const struct file_stream_desc ...@@ -2528,7 +2528,7 @@ static HRESULT opentype_get_font_strings_from_meta(const struct file_stream_desc
token = meta_get_lng_name(NULL, &ctx); token = meta_get_lng_name(NULL, &ctx);
} }
heap_free(ptrW); free(ptrW);
} }
} }
} }
...@@ -2644,13 +2644,13 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR * ...@@ -2644,13 +2644,13 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR *
WCHAR *nameW; WCHAR *nameW;
IDWriteLocalizedStrings_GetStringLength(lfnames, index, &length); IDWriteLocalizedStrings_GetStringLength(lfnames, index, &length);
nameW = heap_alloc((length + 1) * sizeof(WCHAR)); nameW = malloc((length + 1) * sizeof(WCHAR));
if (nameW) if (nameW)
{ {
*nameW = 0; *nameW = 0;
IDWriteLocalizedStrings_GetString(lfnames, index, nameW, length + 1); IDWriteLocalizedStrings_GetString(lfnames, index, nameW, length + 1);
lstrcpynW(lfname, nameW, LF_FACESIZE); lstrcpynW(lfname, nameW, LF_FACESIZE);
heap_free(nameW); free(nameW);
} }
} }
...@@ -4880,7 +4880,7 @@ void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, ...@@ -4880,7 +4880,7 @@ void opentype_layout_apply_gpos_features(struct scriptshaping_context *context,
} }
} }
heap_free(lookups.lookups); free(lookups.lookups);
if (context->has_gpos_attachment) if (context->has_gpos_attachment)
{ {
...@@ -4955,11 +4955,11 @@ static BOOL opentype_layout_gsub_ensure_buffer(struct scriptshaping_context *con ...@@ -4955,11 +4955,11 @@ static BOOL opentype_layout_gsub_ensure_buffer(struct scriptshaping_context *con
new_capacity = context->u.subst.capacity * 2; new_capacity = context->u.subst.capacity * 2;
if ((glyphs = heap_realloc(context->u.subst.glyphs, new_capacity * sizeof(*glyphs)))) if ((glyphs = realloc(context->u.subst.glyphs, new_capacity * sizeof(*glyphs))))
context->u.subst.glyphs = glyphs; context->u.subst.glyphs = glyphs;
if ((glyph_props = heap_realloc(context->u.subst.glyph_props, new_capacity * sizeof(*glyph_props)))) if ((glyph_props = realloc(context->u.subst.glyph_props, new_capacity * sizeof(*glyph_props))))
context->u.subst.glyph_props = glyph_props; context->u.subst.glyph_props = glyph_props;
if ((glyph_infos = heap_realloc(context->glyph_infos, new_capacity * sizeof(*glyph_infos)))) if ((glyph_infos = realloc(context->glyph_infos, new_capacity * sizeof(*glyph_infos))))
context->glyph_infos = glyph_infos; context->glyph_infos = glyph_infos;
if ((ret = (glyphs && glyph_props && glyph_infos))) if ((ret = (glyphs && glyph_props && glyph_infos)))
...@@ -6110,7 +6110,7 @@ void opentype_layout_apply_gsub_features(struct scriptshaping_context *context, ...@@ -6110,7 +6110,7 @@ void opentype_layout_apply_gsub_features(struct scriptshaping_context *context,
for (j = context->glyph_infos[start_idx].start_text_idx; j < context->length; ++j) for (j = context->glyph_infos[start_idx].start_text_idx; j < context->length; ++j)
context->u.buffer.clustermap[j] = start_idx; context->u.buffer.clustermap[j] = start_idx;
heap_free(lookups.lookups); free(lookups.lookups);
} }
static BOOL opentype_layout_contextual_lookup_is_glyph_covered(struct scriptshaping_context *context, UINT16 glyph, static BOOL opentype_layout_contextual_lookup_is_glyph_covered(struct scriptshaping_context *context, UINT16 glyph,
...@@ -6339,7 +6339,7 @@ BOOL opentype_layout_check_feature(struct scriptshaping_context *context, unsign ...@@ -6339,7 +6339,7 @@ BOOL opentype_layout_check_feature(struct scriptshaping_context *context, unsign
break; break;
} }
heap_free(lookups.lookups); free(lookups.lookups);
return ret; return ret;
} }
...@@ -6396,7 +6396,7 @@ BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface) ...@@ -6396,7 +6396,7 @@ BOOL opentype_has_vertical_variants(struct dwrite_fontface *fontface)
} }
} }
heap_free(lookups.lookups); free(lookups.lookups);
if (count) if (count)
fontface->flags |= FONTFACE_VERTICAL_VARIANTS; fontface->flags |= FONTFACE_VERTICAL_VARIANTS;
...@@ -6422,10 +6422,10 @@ HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, u ...@@ -6422,10 +6422,10 @@ HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, u
context.cache = fontface_get_shaping_cache(fontface); context.cache = fontface_get_shaping_cache(fontface);
context.u.subst.glyphs = glyphs; context.u.subst.glyphs = glyphs;
context.u.subst.glyph_props = heap_calloc(glyph_count, sizeof(*context.u.subst.glyph_props)); context.u.subst.glyph_props = calloc(glyph_count, sizeof(*context.u.subst.glyph_props));
context.u.subst.max_glyph_count = glyph_count; context.u.subst.max_glyph_count = glyph_count;
context.u.subst.capacity = glyph_count; context.u.subst.capacity = glyph_count;
context.glyph_infos = heap_alloc_zero(sizeof(*context.glyph_infos) * glyph_count); context.glyph_infos = calloc(glyph_count, sizeof(*context.glyph_infos));
context.table = &context.cache->gsub; context.table = &context.cache->gsub;
vert_feature.tag = DWRITE_MAKE_OPENTYPE_TAG('v','e','r','t'); vert_feature.tag = DWRITE_MAKE_OPENTYPE_TAG('v','e','r','t');
...@@ -6456,9 +6456,9 @@ HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, u ...@@ -6456,9 +6456,9 @@ HRESULT opentype_get_vertical_glyph_variants(struct dwrite_fontface *fontface, u
} }
} }
heap_free(context.u.subst.glyph_props); free(context.u.subst.glyph_props);
heap_free(context.glyph_infos); free(context.glyph_infos);
heap_free(lookups.lookups); free(lookups.lookups);
return S_OK; return S_OK;
} }
......
...@@ -44,8 +44,7 @@ struct scriptshaping_cache *create_scriptshaping_cache(void *context, const stru ...@@ -44,8 +44,7 @@ struct scriptshaping_cache *create_scriptshaping_cache(void *context, const stru
{ {
struct scriptshaping_cache *cache; struct scriptshaping_cache *cache;
cache = heap_alloc_zero(sizeof(*cache)); if (!(cache = calloc(1, sizeof(*cache))))
if (!cache)
return NULL; return NULL;
cache->font = font_ops; cache->font = font_ops;
...@@ -65,7 +64,7 @@ void release_scriptshaping_cache(struct scriptshaping_cache *cache) ...@@ -65,7 +64,7 @@ void release_scriptshaping_cache(struct scriptshaping_cache *cache)
cache->font->release_font_table(cache->context, cache->gdef.table.context); cache->font->release_font_table(cache->context, cache->gdef.table.context);
cache->font->release_font_table(cache->context, cache->gsub.table.context); cache->font->release_font_table(cache->context, cache->gsub.table.context);
cache->font->release_font_table(cache->context, cache->gpos.table.context); cache->font->release_font_table(cache->context, cache->gpos.table.context);
heap_free(cache); free(cache);
} }
static unsigned int shape_select_script(const struct scriptshaping_cache *cache, DWORD kind, const DWORD *scripts, static unsigned int shape_select_script(const struct scriptshaping_cache *cache, DWORD kind, const DWORD *scripts,
...@@ -269,7 +268,7 @@ HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigne ...@@ -269,7 +268,7 @@ HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigne
if (context->u.pos.glyph_props[i].isZeroWidthSpace) if (context->u.pos.glyph_props[i].isZeroWidthSpace)
context->advances[i] = 0.0f; context->advances[i] = 0.0f;
heap_free(features.features); free(features.features);
return S_OK; return S_OK;
} }
...@@ -347,7 +346,7 @@ HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned i ...@@ -347,7 +346,7 @@ HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned i
shape_get_script_lang_index(context, scripts, MS_GSUB_TAG, &script_index, &language_index); shape_get_script_lang_index(context, scripts, MS_GSUB_TAG, &script_index, &language_index);
opentype_layout_apply_gsub_features(context, script_index, language_index, &features); opentype_layout_apply_gsub_features(context, script_index, language_index, &features);
heap_free(features.features); free(features.features);
return (context->glyph_count <= context->u.subst.max_glyph_count) ? S_OK : E_NOT_SUFFICIENT_BUFFER; return (context->glyph_count <= context->u.subst.max_glyph_count) ? S_OK : E_NOT_SUFFICIENT_BUFFER;
} }
...@@ -393,7 +392,7 @@ HRESULT shape_get_typographic_features(struct scriptshaping_context *context, co ...@@ -393,7 +392,7 @@ HRESULT shape_get_typographic_features(struct scriptshaping_context *context, co
*actual_tagcount = t.count; *actual_tagcount = t.count;
heap_free(t.tags); free(t.tags);
return t.count <= max_tagcount ? S_OK : E_NOT_SUFFICIENT_BUFFER; return t.count <= max_tagcount ? S_OK : E_NOT_SUFFICIENT_BUFFER;
} }
......
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