Module: wine Branch: master Commit: fa4d5b6151e0fe6a0e075b2dd17cfb47066c507f URL: https://source.winehq.org/git/wine.git/?a=commit;h=fa4d5b6151e0fe6a0e075b2dd...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Thu Feb 1 03:25:35 2018 +0330
d2d1: Replace d2d_calloc() with a global heap_calloc() helper.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Michael Stefaniuc mstefani@winehq.org Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d2d1/bitmap.c | 2 +- dlls/d2d1/brush.c | 4 ++-- dlls/d2d1/d2d1_private.h | 9 --------- dlls/d2d1/geometry.c | 4 ++-- dlls/d2d1/render_target.c | 2 +- dlls/d2d1/stroke.c | 2 +- include/wine/heap.h | 9 +++++++++ 7 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index 028fab3..0d4098f 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -511,7 +511,7 @@ HRESULT d2d_bitmap_create_from_wic_bitmap(ID2D1Factory *factory, ID3D10Device *d pitch = ((bpp * size.width) + 15) & ~15; if (pitch / bpp < size.width) return E_OUTOFMEMORY; - if (!(data = d2d_calloc(size.height, pitch))) + if (!(data = heap_calloc(size.height, pitch))) return E_OUTOFMEMORY; data_size = size.height * pitch;
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 0531a3a..c46d940 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -142,7 +142,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D unsigned int i; HRESULT hr;
- if (!(data = d2d_calloc(stop_count, 2 * sizeof(*data)))) + if (!(data = heap_calloc(stop_count, 2 * sizeof(*data)))) { ERR("Failed to allocate data.\n"); return E_OUTOFMEMORY; @@ -205,7 +205,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D (*gradient)->view = view;
(*gradient)->stop_count = stop_count; - if (!((*gradient)->stops = d2d_calloc(stop_count, sizeof(*stops)))) + if (!((*gradient)->stops = heap_calloc(stop_count, sizeof(*stops)))) { ID3D10ShaderResourceView_Release(view); heap_free(*gradient); diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 07f71a0..dbfb83c 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -477,15 +477,6 @@ void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory * ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN; struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface) DECLSPEC_HIDDEN;
-static inline void *d2d_calloc(size_t count, size_t size) -{ - SIZE_T s = count * size; - - if (size && s / size != count) - return NULL; - return heap_alloc(s); -} - static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size) { size_t new_capacity, max_capacity; diff --git a/dlls/d2d1/geometry.c b/dlls/d2d1/geometry.c index 4a2f7d7..5b5a75b 100644 --- a/dlls/d2d1/geometry.c +++ b/dlls/d2d1/geometry.c @@ -2025,7 +2025,7 @@ static HRESULT d2d_path_geometry_triangulate(struct d2d_geometry *geometry) return S_OK; }
- if (!(vertices = d2d_calloc(vertex_count, sizeof(*vertices)))) + if (!(vertices = heap_calloc(vertex_count, sizeof(*vertices)))) return E_OUTOFMEMORY;
for (i = 0, j = 0; i < geometry->u.path.figure_count; ++i) @@ -2792,7 +2792,7 @@ static HRESULT d2d_geometry_resolve_beziers(struct d2d_geometry *geometry) geometry->fill.bezier_vertex_count += 3 * geometry->u.path.figures[i].bezier_control_count; }
- if (!(geometry->fill.bezier_vertices = d2d_calloc(geometry->fill.bezier_vertex_count, + if (!(geometry->fill.bezier_vertices = heap_calloc(geometry->fill.bezier_vertex_count, sizeof(*geometry->fill.bezier_vertices)))) { ERR("Failed to allocate bezier vertices array.\n"); diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c index a202279..7afbc84 100644 --- a/dlls/d2d1/render_target.c +++ b/dlls/d2d1/render_target.c @@ -1162,7 +1162,7 @@ static void d2d_rt_draw_glyph_run_bitmap(struct d2d_d3d_render_target *render_ta
if (texture_type == DWRITE_TEXTURE_CLEARTYPE_3x1) bitmap_size.width *= 3; - if (!(opacity_values = d2d_calloc(bitmap_size.height, bitmap_size.width))) + if (!(opacity_values = heap_calloc(bitmap_size.height, bitmap_size.width))) { ERR("Failed to allocate opacity values.\n"); goto done; diff --git a/dlls/d2d1/stroke.c b/dlls/d2d1/stroke.c index 63f88c7..511c134 100644 --- a/dlls/d2d1/stroke.c +++ b/dlls/d2d1/stroke.c @@ -212,7 +212,7 @@ HRESULT d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *fact if (!dashes || !dash_count) return E_INVALIDARG;
- if (!(style->dashes = d2d_calloc(dash_count, sizeof(*style->dashes)))) + if (!(style->dashes = heap_calloc(dash_count, sizeof(*style->dashes)))) return E_OUTOFMEMORY; memcpy(style->dashes, dashes, dash_count * sizeof(*style->dashes)); style->dash_count = dash_count; diff --git a/include/wine/heap.h b/include/wine/heap.h index 681887b..97d3a56 100644 --- a/include/wine/heap.h +++ b/include/wine/heap.h @@ -46,4 +46,13 @@ static inline void heap_free(void *mem) HeapFree(GetProcessHeap(), 0, mem); }
+static inline void *heap_calloc(SIZE_T count, SIZE_T size) +{ + SIZE_T len = count * size; + + if (size && len / size != count) + return NULL; + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len); +} + #endif /* __WINE_WINE_HEAP_H */