3 commits - src/cairo-analysis-surface.c src/cairo-base64-stream.c src/cairo-base85-stream.c src/cairo-cff-subset.c src/cairo-clip.c src/cairo-clip-tor-scan-converter.c src/cairo-colr-glyph-render.c src/cairo-damage.c src/cairo-default-context.c src/cairo-deflate-stream.c src/cairo-font-face-twin.c src/cairo-font-options.c src/cairo-ft-font.c src/cairo-gstate.c src/cairo-hash.c src/cairo-image-source.c src/cairo-image-surface.c src/cairo-malloc-private.h src/cairo-mempool.c src/cairo-mono-scan-converter.c src/cairo-output-stream.c src/cairo-paginated-surface.c src/cairo-path.c src/cairo-path-fixed.c src/cairo-pattern.c src/cairo-pdf-interchange.c src/cairo-pdf-operators.c src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-quartz-font.c src/cairo-quartz-image-surface.c src/cairo-quartz-surface.c src/cairo-raster-source-pattern.c src/cairo-recording-surface.c src/cairo-region.c src/cairo-scaled-font.c src/cairo-scaled-font-subsets.c src/cairo-script-surface.c src/cairo-s urface.c src/cairo-surface-observer.c src/cairo-surface-snapshot.c src/cairo-surface-subsurface.c src/cairo-svg-glyph-render.c src/cairo-svg-surface.c src/cairo-tag-attributes.c src/cairo-tag-stack.c src/cairo-tee-surface.c src/cairo-tor22-scan-converter.c src/cairo-tor-scan-converter.c src/cairo-toy-font-face.c src/cairo-truetype-subset.c src/cairo-type1-fallback.c src/cairo-type1-subset.c src/cairo-type3-glyph-surface.c src/cairo-user-font.c src/cairo-xcb-connection.c src/cairo-xcb-screen.c src/cairo-xcb-shm.c src/cairo-xcb-surface.c src/cairo-xcb-surface-core.c src/cairo-xcb-surface-render.c src/cairo-xlib-display.c src/cairo-xlib-render-compositor.c src/cairo-xlib-screen.c src/cairo-xlib-source.c src/cairo-xlib-surface.c src/cairo-xlib-surface-shm.c src/cairo-xlib-visual.c src/test-compositor-surface.c src/test-null-compositor-surface.c src/test-paginated-surface.c src/win32
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 24 08:46:55 UTC 2024
src/cairo-analysis-surface.c | 6 ++--
src/cairo-base64-stream.c | 2 -
src/cairo-base85-stream.c | 2 -
src/cairo-cff-subset.c | 43 +++++++++++++++----------------
src/cairo-clip-tor-scan-converter.c | 2 -
src/cairo-clip.c | 10 +++----
src/cairo-colr-glyph-render.c | 4 +-
src/cairo-damage.c | 2 -
src/cairo-default-context.c | 2 -
src/cairo-deflate-stream.c | 2 -
src/cairo-font-face-twin.c | 4 +-
src/cairo-font-options.c | 4 +-
src/cairo-ft-font.c | 16 +++++------
src/cairo-gstate.c | 2 -
src/cairo-hash.c | 6 ++--
src/cairo-image-source.c | 6 ++--
src/cairo-image-surface.c | 2 -
src/cairo-malloc-private.h | 33 ++++++++++++++++++++---
src/cairo-mempool.c | 2 -
src/cairo-mono-scan-converter.c | 2 -
src/cairo-output-stream.c | 14 +++++-----
src/cairo-paginated-surface.c | 2 -
src/cairo-path-fixed.c | 2 -
src/cairo-path.c | 4 +-
src/cairo-pattern.c | 14 +++++-----
src/cairo-pdf-interchange.c | 20 +++++++-------
src/cairo-pdf-operators.c | 2 -
src/cairo-pdf-surface.c | 8 ++---
src/cairo-ps-surface.c | 10 +++----
src/cairo-quartz-font.c | 4 +-
src/cairo-quartz-image-surface.c | 2 -
src/cairo-quartz-surface.c | 6 ++--
src/cairo-raster-source-pattern.c | 2 -
src/cairo-recording-surface.c | 34 ++++++++++++------------
src/cairo-region.c | 8 ++---
src/cairo-scaled-font-subsets.c | 10 +++----
src/cairo-scaled-font.c | 8 ++---
src/cairo-script-surface.c | 12 ++++----
src/cairo-surface-observer.c | 6 ++--
src/cairo-surface-snapshot.c | 4 +-
src/cairo-surface-subsurface.c | 4 +-
src/cairo-surface.c | 2 -
src/cairo-svg-glyph-render.c | 8 ++---
src/cairo-svg-surface.c | 12 ++++----
src/cairo-tag-attributes.c | 2 -
src/cairo-tag-stack.c | 2 -
src/cairo-tee-surface.c | 2 -
src/cairo-tor-scan-converter.c | 2 -
src/cairo-tor22-scan-converter.c | 2 -
src/cairo-toy-font-face.c | 2 -
src/cairo-truetype-subset.c | 11 ++++---
src/cairo-type1-fallback.c | 9 +++---
src/cairo-type1-subset.c | 10 ++++---
src/cairo-type3-glyph-surface.c | 2 -
src/cairo-user-font.c | 4 +-
src/cairo-xcb-connection.c | 9 +++---
src/cairo-xcb-screen.c | 2 -
src/cairo-xcb-shm.c | 2 -
src/cairo-xcb-surface-core.c | 4 +-
src/cairo-xcb-surface-render.c | 8 ++---
src/cairo-xcb-surface.c | 2 -
src/cairo-xlib-display.c | 2 -
src/cairo-xlib-render-compositor.c | 4 +-
src/cairo-xlib-screen.c | 2 -
src/cairo-xlib-source.c | 4 +-
src/cairo-xlib-surface-shm.c | 8 ++---
src/cairo-xlib-surface.c | 2 -
src/cairo-xlib-visual.c | 2 -
src/test-compositor-surface.c | 2 -
src/test-null-compositor-surface.c | 2 -
src/test-paginated-surface.c | 2 -
src/win32/cairo-dwrite-font.cpp | 2 -
src/win32/cairo-win32-device.c | 2 -
src/win32/cairo-win32-display-surface.c | 4 +-
src/win32/cairo-win32-font.c | 4 +-
src/win32/cairo-win32-printing-surface.c | 4 +-
76 files changed, 251 insertions(+), 220 deletions(-)
New commits:
commit b807b7a87a2319e25ef2a72a318fccf2ba3a497f
Merge: 0700bb78a 0cae2a4a7
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Mon Jun 24 08:46:51 2024 +0000
Merge branch 'calloc' into 'master'
Use calloc to allocate structs
See merge request cairo/cairo!566
commit 0cae2a4a748a4cece8759f059a4d63d54f44fcd8
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Fri Jun 21 10:03:52 2024 +0930
Use _cairo_calloc() to allocate structs
To avoid any possibility of uninitialized memory.
The exceptions are:
- where the allocation is immediately overwritten by a memcpy or struct copy.
- arrays of structs to avoid any performance impact (except when the
array is returned by the public API).
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 6889be38f..f6099c41b 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -123,7 +123,7 @@ attach_proxy (cairo_surface_t *source,
{
struct proxy *proxy;
- proxy = _cairo_malloc (sizeof (*proxy));
+ proxy = _cairo_calloc (sizeof (*proxy));
if (unlikely (proxy == NULL))
return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
@@ -953,7 +953,7 @@ _cairo_analysis_surface_create (cairo_surface_t *target,
if (unlikely (status))
return _cairo_surface_create_in_error (status);
- surface = _cairo_malloc (sizeof (cairo_analysis_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_analysis_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -1213,7 +1213,7 @@ _cairo_null_surface_create (cairo_content_t content)
{
cairo_surface_t *surface;
- surface = _cairo_malloc (sizeof (cairo_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_surface_t));
if (unlikely (surface == NULL)) {
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
diff --git a/src/cairo-base64-stream.c b/src/cairo-base64-stream.c
index 7f331e539..95f706668 100644
--- a/src/cairo-base64-stream.c
+++ b/src/cairo-base64-stream.c
@@ -126,7 +126,7 @@ _cairo_base64_stream_create (cairo_output_stream_t *output)
if (output->status)
return _cairo_output_stream_create_in_error (output->status);
- stream = _cairo_malloc (sizeof (cairo_base64_stream_t));
+ stream = _cairo_calloc (sizeof (cairo_base64_stream_t));
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-base85-stream.c b/src/cairo-base85-stream.c
index c7f02ca50..40e0275cb 100644
--- a/src/cairo-base85-stream.c
+++ b/src/cairo-base85-stream.c
@@ -114,7 +114,7 @@ _cairo_base85_stream_create (cairo_output_stream_t *output)
if (output->status)
return _cairo_output_stream_create_in_error (output->status);
- stream = _cairo_malloc (sizeof (cairo_base85_stream_t));
+ stream = _cairo_calloc (sizeof (cairo_base85_stream_t));
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 39a30dff0..076cb2b0a 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -616,7 +616,7 @@ cff_dict_create_operator (int operator,
{
cff_dict_operator_t *op;
- op = _cairo_malloc (sizeof (cff_dict_operator_t));
+ op = _cairo_calloc (sizeof (cff_dict_operator_t));
if (unlikely (op == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index d499bf0ad..0822ea908 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -62,7 +62,7 @@ _cairo_clip_path_create (cairo_clip_t *clip)
clip_path = _freed_pool_get (&clip_path_pool);
if (unlikely (clip_path == NULL)) {
- clip_path = _cairo_malloc (sizeof (cairo_clip_path_t));
+ clip_path = _cairo_calloc (sizeof (cairo_clip_path_t));
if (unlikely (clip_path == NULL))
return NULL;
}
@@ -108,7 +108,7 @@ _cairo_clip_create (void)
clip = _freed_pool_get (&clip_pool);
if (unlikely (clip == NULL)) {
- clip = _cairo_malloc (sizeof (cairo_clip_t));
+ clip = _cairo_calloc (sizeof (cairo_clip_t));
if (unlikely (clip == NULL))
return NULL;
}
@@ -735,7 +735,7 @@ _cairo_rectangle_list_create_in_error (cairo_status_t status)
if (status == CAIRO_STATUS_CLIP_NOT_REPRESENTABLE)
return (cairo_rectangle_list_t*) &_cairo_rectangles_not_representable;
- list = _cairo_malloc (sizeof (*list));
+ list = _cairo_calloc (sizeof (*list));
if (unlikely (list == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_rectangle_list_t*) &_cairo_rectangles_nil;
@@ -774,7 +774,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
n_rects = cairo_region_num_rectangles (region);
if (n_rects) {
- rectangles = _cairo_malloc_ab (n_rects, sizeof (cairo_rectangle_t));
+ rectangles = _cairo_calloc_ab (n_rects, sizeof (cairo_rectangle_t));
if (unlikely (rectangles == NULL)) {
return ERROR_LIST (CAIRO_STATUS_NO_MEMORY);
}
@@ -795,7 +795,7 @@ _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
}
DONE:
- list = _cairo_malloc (sizeof (cairo_rectangle_list_t));
+ list = _cairo_calloc (sizeof (cairo_rectangle_list_t));
if (unlikely (list == NULL)) {
free (rectangles);
return ERROR_LIST (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-damage.c b/src/cairo-damage.c
index 97d9fe909..4db9ad1df 100644
--- a/src/cairo-damage.c
+++ b/src/cairo-damage.c
@@ -51,7 +51,7 @@ _cairo_damage_create (void)
{
cairo_damage_t *damage;
- damage = _cairo_malloc (sizeof (*damage));
+ damage = _cairo_calloc (sizeof (*damage));
if (unlikely (damage == NULL)) {
_cairo_error_throw(CAIRO_STATUS_NO_MEMORY);
return (cairo_damage_t *) &__cairo_damage__nil;
diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c
index 87370cdc7..524a11d45 100644
--- a/src/cairo-default-context.c
+++ b/src/cairo-default-context.c
@@ -1508,7 +1508,7 @@ _cairo_default_context_create (void *target)
cr = _freed_pool_get (&context_pool);
if (unlikely (cr == NULL)) {
- cr = _cairo_malloc (sizeof (cairo_default_context_t));
+ cr = _cairo_calloc (sizeof (cairo_default_context_t));
if (unlikely (cr == NULL))
return _cairo_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
diff --git a/src/cairo-deflate-stream.c b/src/cairo-deflate-stream.c
index b51a6399c..d251897eb 100644
--- a/src/cairo-deflate-stream.c
+++ b/src/cairo-deflate-stream.c
@@ -124,7 +124,7 @@ _cairo_deflate_stream_create (cairo_output_stream_t *output)
if (output->status)
return _cairo_output_stream_create_in_error (output->status);
- stream = _cairo_malloc (sizeof (cairo_deflate_stream_t));
+ stream = _cairo_calloc (sizeof (cairo_deflate_stream_t));
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-font-face-twin.c b/src/cairo-font-face-twin.c
index a0855c9f6..771288d68 100644
--- a/src/cairo-font-face-twin.c
+++ b/src/cairo-font-face-twin.c
@@ -288,7 +288,7 @@ twin_font_face_create_properties (cairo_font_face_t *twin_face)
{
twin_face_properties_t *props;
- props = _cairo_malloc (sizeof (twin_face_properties_t));
+ props = _cairo_calloc (sizeof (twin_face_properties_t));
if (unlikely (props == NULL))
return NULL;
@@ -412,7 +412,7 @@ twin_scaled_font_compute_properties (cairo_scaled_font_t *scaled_font,
cairo_status_t status;
twin_scaled_properties_t *props;
- props = _cairo_malloc (sizeof (twin_scaled_properties_t));
+ props = _cairo_calloc (sizeof (twin_scaled_properties_t));
if (unlikely (props == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index 16acf92cf..d5c6663be 100644
--- a/src/cairo-font-options.c
+++ b/src/cairo-font-options.c
@@ -159,7 +159,7 @@ cairo_font_options_create (void)
{
cairo_font_options_t *options;
- options = _cairo_malloc (sizeof (cairo_font_options_t));
+ options = _cairo_calloc (sizeof (cairo_font_options_t));
if (!options) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_options_t *) &_cairo_font_options_nil;
@@ -193,7 +193,7 @@ cairo_font_options_copy (const cairo_font_options_t *original)
if (cairo_font_options_status ((cairo_font_options_t *) original))
return (cairo_font_options_t *) &_cairo_font_options_nil;
- options = _cairo_malloc (sizeof (cairo_font_options_t));
+ options = _cairo_calloc (sizeof (cairo_font_options_t));
if (!options) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_options_t *) &_cairo_font_options_nil;
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index d34db4ceb..360f03fda 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -316,7 +316,7 @@ _cairo_ft_unscaled_font_map_create (void)
* detect some other call path. */
assert (cairo_ft_unscaled_font_map == NULL);
- font_map = _cairo_malloc (sizeof (cairo_ft_unscaled_font_map_t));
+ font_map = _cairo_calloc (sizeof (cairo_ft_unscaled_font_map_t));
if (unlikely (font_map == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -576,7 +576,7 @@ _cairo_ft_unscaled_font_create_internal (cairo_bool_t from_face,
}
/* Otherwise create it and insert into hash table. */
- unscaled = _cairo_malloc (sizeof (cairo_ft_unscaled_font_t));
+ unscaled = _cairo_calloc (sizeof (cairo_ft_unscaled_font_t));
if (unlikely (unscaled == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto UNWIND_FONT_MAP_LOCK;
@@ -2022,7 +2022,7 @@ _cairo_ft_font_face_scaled_font_create (void *abstract_font_face,
if (unlikely (face == NULL)) /* backend error */
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- scaled_font = _cairo_malloc (sizeof (cairo_ft_scaled_font_t));
+ scaled_font = _cairo_calloc (sizeof (cairo_ft_scaled_font_t));
if (unlikely (scaled_font == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL;
@@ -3221,7 +3221,7 @@ _cairo_ft_scaled_glyph_init_metrics (cairo_ft_scaled_font_t *scaled_font,
* cairo_ft_glyph_private_t struct and determine the glyph type.
*/
- glyph_priv = _cairo_malloc (sizeof (*glyph_priv));
+ glyph_priv = _cairo_calloc (sizeof (*glyph_priv));
if (unlikely (glyph_priv == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -4032,7 +4032,7 @@ _cairo_ft_font_face_create_for_pattern (FcPattern *pattern)
{
cairo_ft_font_face_t *font_face;
- font_face = _cairo_malloc (sizeof (cairo_ft_font_face_t));
+ font_face = _cairo_calloc (sizeof (cairo_ft_font_face_t));
if (unlikely (font_face == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_face_t *) &_cairo_font_face_nil;
@@ -4094,7 +4094,7 @@ _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
}
/* No match found, create a new one */
- font_face = _cairo_malloc (sizeof (cairo_ft_font_face_t));
+ font_face = _cairo_calloc (sizeof (cairo_ft_font_face_t));
if (unlikely (!font_face)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_face_t *)&_cairo_font_face_nil;
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 323f80488..46d95f346 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -242,7 +242,7 @@ _cairo_gstate_save (cairo_gstate_t **gstate, cairo_gstate_t **freelist)
top = *freelist;
if (top == NULL) {
- top = _cairo_malloc (sizeof (cairo_gstate_t));
+ top = _cairo_calloc (sizeof (cairo_gstate_t));
if (unlikely (top == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
} else
diff --git a/src/cairo-hash.c b/src/cairo-hash.c
index 5bda8fac8..6aba636cf 100644
--- a/src/cairo-hash.c
+++ b/src/cairo-hash.c
@@ -164,7 +164,7 @@ _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal)
{
cairo_hash_table_t *hash_table;
- hash_table = _cairo_malloc (sizeof (cairo_hash_table_t));
+ hash_table = _cairo_calloc (sizeof (cairo_hash_table_t));
if (unlikely (hash_table == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
diff --git a/src/cairo-image-source.c b/src/cairo-image-source.c
index b8c1c88f5..eaf72e2cc 100644
--- a/src/cairo-image-source.c
+++ b/src/cairo-image-source.c
@@ -1104,7 +1104,7 @@ attach_proxy (cairo_surface_t *source,
{
struct proxy *proxy;
- proxy = _cairo_malloc (sizeof (*proxy));
+ proxy = _cairo_calloc (sizeof (*proxy));
if (unlikely (proxy == NULL))
return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
@@ -1529,7 +1529,7 @@ _pixman_image_for_raster (cairo_image_surface_t *dst,
return NULL;
}
- cleanup = _cairo_malloc (sizeof (*cleanup));
+ cleanup = _cairo_calloc (sizeof (*cleanup));
if (unlikely (cleanup == NULL)) {
pixman_image_unref (pixman_image);
_cairo_surface_release_source_image (surface, image, extra);
@@ -1625,7 +1625,7 @@ _cairo_image_source_create_for_pattern (cairo_surface_t *dst,
TRACE ((stderr, "%s\n", __FUNCTION__));
- source = _cairo_malloc (sizeof (cairo_image_source_t));
+ source = _cairo_calloc (sizeof (cairo_image_source_t));
if (unlikely (source == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 32d8a8c38..f18366b63 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -183,7 +183,7 @@ _cairo_image_surface_create_for_pixman_image (pixman_image_t *pixman_image,
{
cairo_image_surface_t *surface;
- surface = _cairo_malloc (sizeof (cairo_image_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_image_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-mono-scan-converter.c b/src/cairo-mono-scan-converter.c
index 32ddfcc51..e7c8ddb1e 100644
--- a/src/cairo-mono-scan-converter.c
+++ b/src/cairo-mono-scan-converter.c
@@ -562,7 +562,7 @@ _cairo_mono_scan_converter_create (int xmin,
cairo_mono_scan_converter_t *self;
cairo_status_t status;
- self = _cairo_malloc (sizeof(struct _cairo_mono_scan_converter));
+ self = _cairo_calloc (sizeof(struct _cairo_mono_scan_converter));
if (unlikely (self == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail_nomem;
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 7305b52ca..799a73e04 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -148,7 +148,7 @@ _cairo_output_stream_create (cairo_write_func_t write_func,
{
cairo_output_stream_with_closure_t *stream;
- stream = _cairo_malloc (sizeof (cairo_output_stream_with_closure_t));
+ stream = _cairo_calloc (sizeof (cairo_output_stream_with_closure_t));
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -174,7 +174,7 @@ _cairo_output_stream_create_in_error (cairo_status_t status)
if (status == CAIRO_STATUS_WRITE_ERROR)
return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
- stream = _cairo_malloc (sizeof (cairo_output_stream_t));
+ stream = _cairo_calloc (sizeof (cairo_output_stream_t));
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -655,7 +655,7 @@ _cairo_output_stream_create_for_file (FILE *file)
return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
}
- stream = _cairo_malloc (sizeof *stream);
+ stream = _cairo_calloc (sizeof *stream);
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -694,7 +694,7 @@ _cairo_output_stream_create_for_filename (const char *filename)
}
}
- stream = _cairo_malloc (sizeof *stream);
+ stream = _cairo_calloc (sizeof *stream);
if (unlikely (stream == NULL)) {
fclose (file);
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
@@ -738,7 +738,7 @@ _cairo_memory_stream_create (void)
{
memory_stream_t *stream;
- stream = _cairo_malloc (sizeof *stream);
+ stream = _cairo_calloc (sizeof *stream);
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -765,7 +765,7 @@ _cairo_memory_stream_destroy (cairo_output_stream_t *abstract_stream,
stream = (memory_stream_t *) abstract_stream;
*length_out = _cairo_array_num_elements (&stream->array);
- *data_out = _cairo_malloc (*length_out);
+ *data_out = _cairo_calloc (*length_out);
if (unlikely (*data_out == NULL)) {
status = _cairo_output_stream_destroy (abstract_stream);
assert (status == CAIRO_STATUS_SUCCESS);
@@ -812,7 +812,7 @@ _cairo_null_stream_create (void)
{
cairo_output_stream_t *stream;
- stream = _cairo_malloc (sizeof *stream);
+ stream = _cairo_calloc (sizeof *stream);
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index ac24745e3..ff05ecd51 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -99,7 +99,7 @@ _cairo_paginated_surface_create (cairo_surface_t *target,
cairo_paginated_surface_t *surface;
cairo_status_t status;
- surface = _cairo_malloc (sizeof (cairo_paginated_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_paginated_surface_t));
if (unlikely (surface == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL;
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index fc146f3b3..ca759447e 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -325,7 +325,7 @@ _cairo_path_fixed_create (void)
{
cairo_path_fixed_t *path;
- path = _cairo_malloc (sizeof (cairo_path_fixed_t));
+ path = _cairo_calloc (sizeof (cairo_path_fixed_t));
if (!path) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
diff --git a/src/cairo-path.c b/src/cairo-path.c
index efd84901e..6f7a9cef0 100644
--- a/src/cairo-path.c
+++ b/src/cairo-path.c
@@ -294,7 +294,7 @@ _cairo_path_create_in_error (cairo_status_t status)
if (status == CAIRO_STATUS_NO_MEMORY)
return (cairo_path_t*) &_cairo_path_nil;
- path = _cairo_malloc (sizeof (cairo_path_t));
+ path = _cairo_calloc (sizeof (cairo_path_t));
if (unlikely (path == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_path_t*) &_cairo_path_nil;
@@ -314,7 +314,7 @@ _cairo_path_create_internal (cairo_path_fixed_t *path_fixed,
{
cairo_path_t *path;
- path = _cairo_malloc (sizeof (cairo_path_t));
+ path = _cairo_calloc (sizeof (cairo_path_t));
if (unlikely (path == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_path_t*) &_cairo_path_nil;
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 742c51b2e..4d713e6c6 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -626,7 +626,7 @@ _cairo_pattern_create_solid (const cairo_color_t *color)
_freed_pool_get (&freed_pattern_pool[CAIRO_PATTERN_TYPE_SOLID]);
if (unlikely (pattern == NULL)) {
/* None cached, need to create a new pattern. */
- pattern = _cairo_malloc (sizeof (cairo_solid_pattern_t));
+ pattern = _cairo_calloc (sizeof (cairo_solid_pattern_t));
if (unlikely (pattern == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *) &_cairo_pattern_nil;
@@ -768,7 +768,7 @@ cairo_pattern_create_for_surface (cairo_surface_t *surface)
pattern =
_freed_pool_get (&freed_pattern_pool[CAIRO_PATTERN_TYPE_SURFACE]);
if (unlikely (pattern == NULL)) {
- pattern = _cairo_malloc (sizeof (cairo_surface_pattern_t));
+ pattern = _cairo_calloc (sizeof (cairo_surface_pattern_t));
if (unlikely (pattern == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *)&_cairo_pattern_nil.base;
@@ -819,7 +819,7 @@ cairo_pattern_create_linear (double x0, double y0, double x1, double y1)
pattern =
_freed_pool_get (&freed_pattern_pool[CAIRO_PATTERN_TYPE_LINEAR]);
if (unlikely (pattern == NULL)) {
- pattern = _cairo_malloc (sizeof (cairo_linear_pattern_t));
+ pattern = _cairo_calloc (sizeof (cairo_linear_pattern_t));
if (unlikely (pattern == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *) &_cairo_pattern_nil.base;
@@ -873,7 +873,7 @@ cairo_pattern_create_radial (double cx0, double cy0, double radius0,
pattern =
_freed_pool_get (&freed_pattern_pool[CAIRO_PATTERN_TYPE_RADIAL]);
if (unlikely (pattern == NULL)) {
- pattern = _cairo_malloc (sizeof (cairo_radial_pattern_t));
+ pattern = _cairo_calloc (sizeof (cairo_radial_pattern_t));
if (unlikely (pattern == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *) &_cairo_pattern_nil.base;
@@ -1051,7 +1051,7 @@ cairo_pattern_create_mesh (void)
pattern =
_freed_pool_get (&freed_pattern_pool[CAIRO_PATTERN_TYPE_MESH]);
if (unlikely (pattern == NULL)) {
- pattern = _cairo_malloc (sizeof (cairo_mesh_pattern_t));
+ pattern = _cairo_calloc (sizeof (cairo_mesh_pattern_t));
if (unlikely (pattern == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *) &_cairo_pattern_nil.base;
@@ -4547,12 +4547,12 @@ cairo_mesh_pattern_get_path (cairo_pattern_t *pattern,
patch = _cairo_array_index_const (&mesh->patches, patch_num);
- path = _cairo_malloc (sizeof (cairo_path_t));
+ path = _cairo_calloc (sizeof (cairo_path_t));
if (path == NULL)
return _cairo_path_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
path->num_data = 18;
- path->data = _cairo_malloc_ab (path->num_data,
+ path->data = _cairo_calloc_ab (path->num_data,
sizeof (cairo_path_data_t));
if (path->data == NULL) {
free (path);
diff --git a/src/cairo-pdf-interchange.c b/src/cairo-pdf-interchange.c
index c0db4531f..f0540effb 100644
--- a/src/cairo-pdf-interchange.c
+++ b/src/cairo-pdf-interchange.c
@@ -160,7 +160,7 @@ command_list_push_group (cairo_pdf_surface_t *surface,
cairo_pdf_recording_surface_commands_t recording_commands;
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
- group = _cairo_malloc (sizeof(cairo_pdf_command_list_t));
+ group = _cairo_calloc (sizeof(cairo_pdf_command_list_t));
_cairo_array_init (&group->commands, sizeof(cairo_pdf_command_t));
group->parent = ic->current_commands;
@@ -374,7 +374,7 @@ add_tree_node (cairo_pdf_surface_t *surface,
cairo_pdf_struct_tree_node_t *node;
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
- node = _cairo_malloc (sizeof(cairo_pdf_struct_tree_node_t));
+ node = _cairo_calloc (sizeof(cairo_pdf_struct_tree_node_t));
if (unlikely (node == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -484,7 +484,7 @@ add_annotation (cairo_pdf_surface_t *surface,
cairo_pdf_interchange_t *ic = &surface->interchange;
cairo_pdf_annotation_t *annot;
- annot = _cairo_malloc (sizeof (cairo_pdf_annotation_t));
+ annot = _cairo_calloc (sizeof (cairo_pdf_annotation_t));
if (unlikely (annot == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1766,7 +1766,7 @@ _cairo_pdf_interchange_begin_structure_tag (cairo_pdf_surface_t *surface,
return status;
/* Add to command_id to node map. */
- command_entry = _cairo_malloc (sizeof(cairo_pdf_command_entry_t));
+ command_entry = _cairo_calloc (sizeof(cairo_pdf_command_entry_t));
command_entry->recording_id = ic->recording_id;
command_entry->command_id = ic->command_id;
command_entry->node = ic->current_analyze_node;
@@ -1782,7 +1782,7 @@ _cairo_pdf_interchange_begin_structure_tag (cairo_pdf_surface_t *surface,
}
if (ic->current_analyze_node->type == PDF_NODE_CONTENT) {
- cairo_pdf_content_tag_t *content = _cairo_malloc (sizeof(cairo_pdf_content_tag_t));
+ cairo_pdf_content_tag_t *content = _cairo_calloc (sizeof(cairo_pdf_content_tag_t));
content->node = ic->current_analyze_node;
_cairo_pdf_content_tag_init_key (content);
status = _cairo_hash_table_insert (ic->content_tag_map, &content->base);
@@ -2597,7 +2597,7 @@ _cairo_pdf_interchange_add_outline (cairo_pdf_surface_t *surface,
if (parent_id < 0 || parent_id >= (int)_cairo_array_num_elements (&ic->outline))
return CAIRO_STATUS_SUCCESS;
- outline = _cairo_malloc (sizeof(cairo_pdf_outline_entry_t));
+ outline = _cairo_calloc (sizeof(cairo_pdf_outline_entry_t));
if (unlikely (outline == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-pdf-operators.c b/src/cairo-pdf-operators.c
index 176f45b48..7bed41310 100644
--- a/src/cairo-pdf-operators.c
+++ b/src/cairo-pdf-operators.c
@@ -359,7 +359,7 @@ _word_wrap_stream_create (cairo_output_stream_t *output, cairo_bool_t ps, int ma
if (output->status)
return _cairo_output_stream_create_in_error (output->status);
- stream = _cairo_malloc (sizeof (word_wrap_stream_t));
+ stream = _cairo_calloc (sizeof (word_wrap_stream_t));
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 0ae8745ac..3e734c759 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -447,7 +447,7 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *output,
cairo_pdf_surface_t *surface;
cairo_status_t status, status_ignored;
- surface = _cairo_malloc (sizeof (cairo_pdf_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_pdf_surface_t));
if (unlikely (surface == NULL)) {
/* destroy stream on behalf of caller */
status = _cairo_output_stream_destroy (output);
@@ -1766,7 +1766,7 @@ _cairo_pdf_surface_add_source_surface (cairo_pdf_surface_t *surface,
unique_id_length = 0;
}
- surface_entry = _cairo_malloc (sizeof (cairo_pdf_source_surface_entry_t));
+ surface_entry = _cairo_calloc (sizeof (cairo_pdf_source_surface_entry_t));
if (surface_entry == NULL) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
@@ -9397,7 +9397,7 @@ _cairo_pdf_surface_supports_color_glyph (void *abstract_surface
if (glyph_entry)
return glyph_entry->supported;
- glyph_entry = _cairo_malloc (sizeof (cairo_pdf_color_glyph_t));
+ glyph_entry = _cairo_calloc (sizeof (cairo_pdf_color_glyph_t));
if (glyph_entry == NULL) {
status = _cairo_surface_set_error (&surface->base,
_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 30a5c908f..1d2bba20e 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1065,7 +1065,7 @@ _cairo_ps_surface_get_page_media (cairo_ps_surface_t *surface)
}
}
- page = _cairo_malloc (sizeof (cairo_page_media_t));
+ page = _cairo_calloc (sizeof (cairo_page_media_t));
if (unlikely (page == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
@@ -1101,7 +1101,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream,
cairo_status_t status, status_ignored;
cairo_ps_surface_t *surface;
- surface = _cairo_malloc (sizeof (cairo_ps_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_ps_surface_t));
if (unlikely (surface == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP;
@@ -2351,7 +2351,7 @@ _base85_strings_stream_create (cairo_output_stream_t *output)
{
string_array_stream_t *stream;
- stream = _cairo_malloc (sizeof (string_array_stream_t));
+ stream = _cairo_calloc (sizeof (string_array_stream_t));
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
@@ -2381,7 +2381,7 @@ _base85_wrap_stream_create (cairo_output_stream_t *output)
{
string_array_stream_t *stream;
- stream = _cairo_malloc (sizeof (string_array_stream_t));
+ stream = _cairo_calloc (sizeof (string_array_stream_t));
if (unlikely (stream == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index b7efc54de..b1a6fd7f5 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -261,7 +261,7 @@ _cairo_quartz_font_face_scaled_font_create (void *abstract_face,
CTFontRef ctFont;
CGRect bbox;
- font = _cairo_malloc (sizeof(cairo_quartz_scaled_font_t));
+ font = _cairo_calloc (sizeof(cairo_quartz_scaled_font_t));
if (font == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -318,7 +318,7 @@ static inline cairo_quartz_font_face_t*
_cairo_quartz_font_face_create ()
{
cairo_quartz_font_face_t *font_face =
- _cairo_malloc (sizeof (cairo_quartz_font_face_t));
+ _cairo_calloc (sizeof (cairo_quartz_font_face_t));
if (!font_face) {
cairo_status_t ignore_status;
diff --git a/src/cairo-quartz-image-surface.c b/src/cairo-quartz-image-surface.c
index 9056a7b68..4f9bc2118 100644
--- a/src/cairo-quartz-image-surface.c
+++ b/src/cairo-quartz-image-surface.c
@@ -292,7 +292,7 @@ cairo_quartz_image_surface_create (cairo_surface_t *surface)
if (format != CAIRO_FORMAT_ARGB32 && format != CAIRO_FORMAT_RGB24)
return SURFACE_ERROR_INVALID_FORMAT;
- qisurf = _cairo_malloc (sizeof(cairo_quartz_image_surface_t));
+ qisurf = _cairo_calloc (sizeof(cairo_quartz_image_surface_t));
if (qisurf == NULL)
return SURFACE_ERROR_NO_MEMORY;
diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 6da1b6ffa..0a5c72f0d 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -851,7 +851,7 @@ _cairo_quartz_cairo_repeating_surface_pattern_to_quartz (cairo_quartz_surface_t
if (unlikely (status))
return status;
- info = _cairo_malloc (sizeof (SurfacePatternDrawInfo));
+ info = _cairo_calloc (sizeof (SurfacePatternDrawInfo));
if (unlikely (!info))
{
CGImageRelease (image);
@@ -2136,7 +2136,7 @@ _cairo_quartz_surface_create_internal (CGContextRef cgContext,
cairo_quartz_surface_t *surface;
/* Init the base surface */
- surface = _cairo_malloc (sizeof (cairo_quartz_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_quartz_surface_t));
if (unlikely (surface == NULL))
return (cairo_quartz_surface_t*) _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -2386,7 +2386,7 @@ _cairo_quartz_snapshot_create (cairo_surface_t *surface)
! _cairo_quartz_is_cgcontext_bitmap_context (((cairo_quartz_surface_t*)surface)->cgContext))
return NULL;
- snapshot = _cairo_malloc (sizeof (cairo_quartz_snapshot_t));
+ snapshot = _cairo_calloc (sizeof (cairo_quartz_snapshot_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c
index 92efd6bbe..6add3a218 100644
--- a/src/cairo-recording-surface.c
+++ b/src/cairo-recording-surface.c
@@ -168,7 +168,7 @@ static int bbtree_left_or_right (struct bbtree *bbt,
static struct bbtree *
bbtree_new (const cairo_box_t *box, cairo_command_header_t *chain)
{
- struct bbtree *bbt = _cairo_malloc (sizeof (*bbt));
+ struct bbtree *bbt = _cairo_calloc (sizeof (*bbt));
if (bbt == NULL)
return NULL;
bbt->extents = *box;
@@ -399,7 +399,7 @@ cairo_recording_surface_create (cairo_content_t content,
{
cairo_recording_surface_t *surface;
- surface = _cairo_malloc (sizeof (cairo_recording_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_recording_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -653,7 +653,7 @@ attach_proxy (cairo_surface_t *source,
{
struct proxy *proxy;
- proxy = _cairo_malloc (sizeof (*proxy));
+ proxy = _cairo_calloc (sizeof (*proxy));
if (unlikely (proxy == NULL))
return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
@@ -822,7 +822,7 @@ _cairo_recording_surface_paint (void *abstract_surface,
if (unlikely (status))
return status;
- command = _cairo_malloc (sizeof (cairo_command_paint_t));
+ command = _cairo_calloc (sizeof (cairo_command_paint_t));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_COMPOSITE;
@@ -878,7 +878,7 @@ _cairo_recording_surface_mask (void *abstract_surface,
if (unlikely (status))
return status;
- command = _cairo_malloc (sizeof (cairo_command_mask_t));
+ command = _cairo_calloc (sizeof (cairo_command_mask_t));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_COMPOSITE;
@@ -946,7 +946,7 @@ _cairo_recording_surface_stroke (void *abstract_surface,
if (unlikely (status))
return status;
- command = _cairo_malloc (sizeof (cairo_command_stroke_t));
+ command = _cairo_calloc (sizeof (cairo_command_stroke_t));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_COMPOSITE;
@@ -1022,7 +1022,7 @@ _cairo_recording_surface_fill (void *abstract_surface,
if (unlikely (status))
return status;
- command = _cairo_malloc (sizeof (cairo_command_fill_t));
+ command = _cairo_calloc (sizeof (cairo_command_fill_t));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_COMPOSITE;
@@ -1104,7 +1104,7 @@ _cairo_recording_surface_show_text_glyphs (void *abstract_surface,
if (unlikely (status))
return status;
- command = _cairo_malloc (sizeof (cairo_command_show_text_glyphs_t));
+ command = _cairo_calloc (sizeof (cairo_command_show_text_glyphs_t));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_COMPOSITE;
@@ -1271,7 +1271,7 @@ _cairo_recording_surface_copy__paint (cairo_recording_surface_t *surface,
cairo_command_paint_t *command;
cairo_status_t status;
- command = _cairo_malloc (sizeof (*command));
+ command = _cairo_calloc (sizeof (*command));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err;
@@ -1305,7 +1305,7 @@ _cairo_recording_surface_copy__mask (cairo_recording_surface_t *surface,
cairo_command_mask_t *command;
cairo_status_t status;
- command = _cairo_malloc (sizeof (*command));
+ command = _cairo_calloc (sizeof (*command));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err;
@@ -1346,7 +1346,7 @@ _cairo_recording_surface_copy__stroke (cairo_recording_surface_t *surface,
cairo_command_stroke_t *command;
cairo_status_t status;
- command = _cairo_malloc (sizeof (*command));
+ command = _cairo_calloc (sizeof (*command));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err;
@@ -1398,7 +1398,7 @@ _cairo_recording_surface_copy__fill (cairo_recording_surface_t *surface,
cairo_command_fill_t *command;
cairo_status_t status;
- command = _cairo_malloc (sizeof (*command));
+ command = _cairo_calloc (sizeof (*command));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err;
@@ -1442,7 +1442,7 @@ _cairo_recording_surface_copy__glyphs (cairo_recording_surface_t *surface,
cairo_command_show_text_glyphs_t *command;
cairo_status_t status;
- command = _cairo_malloc (sizeof (*command));
+ command = _cairo_calloc (sizeof (*command));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err;
@@ -1627,7 +1627,7 @@ _cairo_recording_surface_snapshot (void *abstract_other)
cairo_recording_surface_t *surface;
cairo_status_t status;
- surface = _cairo_malloc (sizeof (cairo_recording_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_recording_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -1776,7 +1776,7 @@ _cairo_recording_surface_region_array_attach (cairo_surface_t *abstract_surface,
assert (_cairo_surface_is_recording (abstract_surface));
- region_array = _cairo_malloc (sizeof (cairo_recording_regions_array_t));
+ region_array = _cairo_calloc (sizeof (cairo_recording_regions_array_t));
if (region_array == NULL) {
*id = 0;
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-region.c b/src/cairo-region.c
index 320a23fa9..610747294 100644
--- a/src/cairo-region.c
+++ b/src/cairo-region.c
@@ -202,7 +202,7 @@ cairo_region_create (void)
{
cairo_region_t *region;
- region = _cairo_malloc (sizeof (cairo_region_t));
+ region = _cairo_calloc (sizeof (cairo_region_t));
if (region == NULL)
return (cairo_region_t *) &_cairo_region_nil;
@@ -238,7 +238,7 @@ cairo_region_create_rectangles (const cairo_rectangle_int_t *rects,
cairo_region_t *region;
int i;
- region = _cairo_malloc (sizeof (cairo_region_t));
+ region = _cairo_calloc (sizeof (cairo_region_t));
if (unlikely (region == NULL))
return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -286,7 +286,7 @@ _cairo_region_create_from_boxes (const cairo_box_t *boxes, int count)
{
cairo_region_t *region;
- region = _cairo_malloc (sizeof (cairo_region_t));
+ region = _cairo_calloc (sizeof (cairo_region_t));
if (unlikely (region == NULL))
return _cairo_region_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -332,7 +332,7 @@ cairo_region_create_rectangle (const cairo_rectangle_int_t *rectangle)
{
cairo_region_t *region;
- region = _cairo_malloc (sizeof (cairo_region_t));
+ region = _cairo_calloc (sizeof (cairo_region_t));
if (unlikely (region == NULL))
return (cairo_region_t *) &_cairo_region_nil;
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index ed898d405..f15f819a0 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -166,7 +166,7 @@ _cairo_sub_font_glyph_create (unsigned long scaled_font_glyph_index,
{
cairo_sub_font_glyph_t *sub_font_glyph;
- sub_font_glyph = _cairo_malloc (sizeof (cairo_sub_font_glyph_t));
+ sub_font_glyph = _cairo_calloc (sizeof (cairo_sub_font_glyph_t));
if (unlikely (sub_font_glyph == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
@@ -276,7 +276,7 @@ _cairo_sub_font_create (cairo_scaled_font_subsets_t *parent,
cairo_sub_font_t *sub_font;
int i;
- sub_font = _cairo_malloc (sizeof (cairo_sub_font_t));
+ sub_font = _cairo_calloc (sizeof (cairo_sub_font_t));
if (unlikely (sub_font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -749,7 +749,7 @@ _cairo_scaled_font_subsets_create_internal (cairo_subsets_type_t type)
{
cairo_scaled_font_subsets_t *subsets;
- subsets = _cairo_malloc (sizeof (cairo_scaled_font_subsets_t));
+ subsets = _cairo_calloc (sizeof (cairo_scaled_font_subsets_t));
if (unlikely (subsets == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
@@ -1206,7 +1206,7 @@ _cairo_string_init_key (cairo_string_entry_t *key, char *s)
static cairo_status_t
create_string_entry (char *s, cairo_string_entry_t **entry)
{
- *entry = _cairo_malloc (sizeof (cairo_string_entry_t));
+ *entry = _cairo_calloc (sizeof (cairo_string_entry_t));
if (unlikely (*entry == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 70d1eab2a..82a4447f5 100755
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -378,7 +378,7 @@ _cairo_scaled_font_map_lock (void)
CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
if (cairo_scaled_font_map == NULL) {
- cairo_scaled_font_map = _cairo_malloc (sizeof (cairo_scaled_font_map_t));
+ cairo_scaled_font_map = _cairo_calloc (sizeof (cairo_scaled_font_map_t));
if (unlikely (cairo_scaled_font_map == NULL))
goto CLEANUP_MUTEX_LOCK;
@@ -519,7 +519,7 @@ _cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t
if (unlikely (status))
return status;
- placeholder_scaled_font = _cairo_malloc (sizeof (cairo_scaled_font_t));
+ placeholder_scaled_font = _cairo_calloc (sizeof (cairo_scaled_font_t));
if (unlikely (placeholder_scaled_font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1263,7 +1263,7 @@ _cairo_scaled_font_create_in_error (cairo_status_t status)
CAIRO_MUTEX_LOCK (_cairo_scaled_font_error_mutex);
scaled_font = _cairo_scaled_font_nil_objects[status];
if (unlikely (scaled_font == NULL)) {
- scaled_font = _cairo_malloc (sizeof (cairo_scaled_font_t));
+ scaled_font = _cairo_calloc (sizeof (cairo_scaled_font_t));
if (unlikely (scaled_font == NULL)) {
CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_error_mutex);
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
@@ -2759,7 +2759,7 @@ _cairo_scaled_font_allocate_glyph (cairo_scaled_font_t *scaled_font,
}
}
- page = _cairo_malloc (sizeof (cairo_scaled_glyph_page_t));
+ page = _cairo_calloc (sizeof (cairo_scaled_glyph_page_t));
if (unlikely (page == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index 46790ab9a..6d25acd38 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -264,7 +264,7 @@ _bitmap_next_id (struct _bitmap *b,
} while (b != NULL);
assert (prev != NULL);
- bb = _cairo_malloc (sizeof (struct _bitmap));
+ bb = _cairo_calloc (sizeof (struct _bitmap));
if (unlikely (bb == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1144,7 +1144,7 @@ attach_snapshot (cairo_script_context_t *ctx,
if (! ctx->attach_snapshots)
return;
- surface = _cairo_malloc (sizeof (*surface));
+ surface = _cairo_calloc (sizeof (*surface));
if (unlikely (surface == NULL))
return;
@@ -2258,7 +2258,7 @@ _cairo_script_surface_finish (void *abstract_surface)
}
cairo_list_del (&surface->operand.link);
} else {
- struct deferred_finish *link = _cairo_malloc (sizeof (*link));
+ struct deferred_finish *link = _cairo_calloc (sizeof (*link));
if (link == NULL) {
status2 = _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (status == CAIRO_STATUS_SUCCESS)
@@ -2992,7 +2992,7 @@ _emit_scaled_font_init (cairo_script_surface_t *surface,
cairo_script_font_t *font_private;
cairo_int_status_t status;
- font_private = _cairo_malloc (sizeof (cairo_script_font_t));
+ font_private = _cairo_calloc (sizeof (cairo_script_font_t));
if (unlikely (font_private == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -3728,7 +3728,7 @@ _cairo_script_surface_create_internal (cairo_script_context_t *ctx,
if (unlikely (ctx == NULL))
return (cairo_script_surface_t *) _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NULL_POINTER));
- surface = _cairo_malloc (sizeof (cairo_script_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_script_surface_t));
if (unlikely (surface == NULL))
return (cairo_script_surface_t *) _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -3777,7 +3777,7 @@ _cairo_script_context_create_internal (cairo_output_stream_t *stream)
{
cairo_script_context_t *ctx;
- ctx = _cairo_malloc (sizeof (cairo_script_context_t));
+ ctx = _cairo_calloc (sizeof (cairo_script_context_t));
if (unlikely (ctx == NULL))
return _cairo_device_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c
index 83aa41801..9ff21fc27 100644
--- a/src/cairo-surface-observer.c
+++ b/src/cairo-surface-observer.c
@@ -366,7 +366,7 @@ _cairo_device_create_observer_internal (cairo_device_t *target,
cairo_device_observer_t *device;
cairo_status_t status;
- device = _cairo_malloc (sizeof (cairo_device_observer_t));
+ device = _cairo_calloc (sizeof (cairo_device_observer_t));
if (unlikely (device == NULL))
return _cairo_device_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -397,7 +397,7 @@ _cairo_surface_create_observer_internal (cairo_device_t *device,
cairo_surface_observer_t *surface;
cairo_status_t status;
- surface = _cairo_malloc (sizeof (cairo_surface_observer_t));
+ surface = _cairo_calloc (sizeof (cairo_surface_observer_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -1436,7 +1436,7 @@ _cairo_surface_observer_add_callback (cairo_list_t *head,
{
struct callback_list *cb;
- cb = _cairo_malloc (sizeof (*cb));
+ cb = _cairo_calloc (sizeof (*cb));
if (unlikely (cb == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-surface-snapshot.c b/src/cairo-surface-snapshot.c
index b2908f6bc..dd4a25364 100644
--- a/src/cairo-surface-snapshot.c
+++ b/src/cairo-surface-snapshot.c
@@ -101,7 +101,7 @@ _cairo_surface_snapshot_acquire_source_image (void *abstract_
struct snapshot_extra *extra;
cairo_status_t status;
- extra = _cairo_malloc (sizeof (*extra));
+ extra = _cairo_calloc (sizeof (*extra));
if (unlikely (extra == NULL)) {
*extra_out = NULL;
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -263,7 +263,7 @@ _cairo_surface_snapshot (cairo_surface_t *surface)
if (snapshot != NULL)
return cairo_surface_reference (&snapshot->base);
- snapshot = _cairo_malloc (sizeof (cairo_surface_snapshot_t));
+ snapshot = _cairo_calloc (sizeof (cairo_surface_snapshot_t));
if (unlikely (snapshot == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED));
diff --git a/src/cairo-surface-subsurface.c b/src/cairo-surface-subsurface.c
index b2a10e9bc..9818c7296 100644
--- a/src/cairo-surface-subsurface.c
+++ b/src/cairo-surface-subsurface.c
@@ -462,7 +462,7 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target,
if (unlikely (target->finished))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED));
- surface = _cairo_malloc (sizeof (cairo_surface_subsurface_t));
+ surface = _cairo_calloc (sizeof (cairo_surface_subsurface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -522,7 +522,7 @@ _cairo_surface_create_for_rectangle_int (cairo_surface_t *target,
assert (target->backend->type != CAIRO_SURFACE_TYPE_SUBSURFACE);
- surface = _cairo_malloc (sizeof (cairo_surface_subsurface_t));
+ surface = _cairo_calloc (sizeof (cairo_surface_subsurface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index a8117d699..86c1837b9 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1449,7 +1449,7 @@ cairo_surface_set_mime_data (cairo_surface_t *surface,
return _cairo_surface_set_error (surface, status);
if (data != NULL) {
- mime_data = _cairo_malloc (sizeof (cairo_mime_data_t));
+ mime_data = _cairo_calloc (sizeof (cairo_mime_data_t));
if (unlikely (mime_data == NULL))
return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-svg-glyph-render.c b/src/cairo-svg-glyph-render.c
index 01f990060..9a9da2e46 100644
--- a/src/cairo-svg-glyph-render.c
+++ b/src/cairo-svg-glyph-render.c
@@ -1028,7 +1028,7 @@ create_element (tag_type_t type, char *tag)
cairo_svg_element_t *elem;
cairo_status_t status;
- elem = _cairo_malloc (sizeof (cairo_svg_element_t));
+ elem = _cairo_calloc (sizeof (cairo_svg_element_t));
if (unlikely (elem == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
return NULL;
@@ -2589,7 +2589,7 @@ init_graphics_state (cairo_svg_glyph_render_t *svg_render)
{
cairo_svg_graphics_state_t *gs;
- gs = _cairo_malloc (sizeof (cairo_svg_graphics_state_t));
+ gs = _cairo_calloc (sizeof (cairo_svg_graphics_state_t));
get_paint (svg_render, "black", &gs->fill);
get_paint (svg_render, "none", &gs->stroke);
gs->color.type = FOREGROUND;
@@ -2881,7 +2881,7 @@ save_graphics_state (cairo_svg_glyph_render_t *svg_render)
cairo_save (svg_render->cr);
- gs = _cairo_malloc (sizeof (cairo_svg_graphics_state_t));
+ gs = _cairo_calloc (sizeof (cairo_svg_graphics_state_t));
gs->fill = svg_render->graphics_state->fill;
gs->stroke = svg_render->graphics_state->stroke;
gs->color = svg_render->graphics_state->color;
@@ -3102,7 +3102,7 @@ _cairo_render_svg_glyph (const char *svg_document,
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
- cairo_svg_glyph_render_t *svg_render = _cairo_malloc (sizeof (cairo_svg_glyph_render_t));
+ cairo_svg_glyph_render_t *svg_render = _cairo_calloc (sizeof (cairo_svg_glyph_render_t));
if (unlikely (svg_render == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index b7212a547..249f46f53 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -940,7 +940,7 @@ _cairo_svg_surface_add_source_surface (cairo_svg_surface_t *surface,
unique_id_length = 0;
}
- cairo_svg_source_surface_t *source_surface_entry = malloc (sizeof (cairo_svg_source_surface_t));
+ cairo_svg_source_surface_t *source_surface_entry = _cairo_calloc (sizeof (cairo_svg_source_surface_t));
if (source_surface_entry == NULL) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
@@ -1060,7 +1060,7 @@ _cairo_svg_surface_create_for_document (cairo_svg_document_t *document,
cairo_surface_t *paginated;
cairo_status_t status;
- surface = _cairo_malloc (sizeof (cairo_svg_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_svg_surface_t));
if (unlikely (surface == NULL)) {
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
@@ -1459,7 +1459,7 @@ _cairo_svg_document_emit_bitmap_glyph_data (cairo_svg_document_t *document,
}
_cairo_svg_stream_printf (&document->xml_node_glyphs, "/>\n");
- cairo_svg_paint_t *paint_entry = malloc (sizeof (cairo_svg_paint_t));
+ cairo_svg_paint_t *paint_entry = _cairo_calloc (sizeof (cairo_svg_paint_t));
if (paint_entry == NULL) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto cleanup;
@@ -2392,7 +2392,7 @@ _cairo_svg_surface_emit_composite_recording_pattern (cairo_svg_stream_t *output,
}
if (source_surface->transitive_paint_used) {
- cairo_svg_paint_t *paint_entry = malloc (sizeof (cairo_svg_paint_t));
+ cairo_svg_paint_t *paint_entry = _cairo_calloc (sizeof (cairo_svg_paint_t));
if (paint_entry == NULL) {
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -4175,7 +4175,7 @@ _cairo_svg_document_create (cairo_output_stream_t *output_stream,
return output_stream->status;
}
- document = _cairo_malloc (sizeof (cairo_svg_document_t));
+ document = _cairo_calloc (sizeof (cairo_svg_document_t));
if (unlikely (document == NULL)) {
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -4316,7 +4316,7 @@ _cairo_svg_document_finish (cairo_svg_document_t *document)
}
if (surface->transitive_paint_used) {
- cairo_svg_paint_t *paint_entry = malloc (sizeof (cairo_svg_paint_t));
+ cairo_svg_paint_t *paint_entry = _cairo_calloc (sizeof (cairo_svg_paint_t));
if (paint_entry == NULL) {
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
diff --git a/src/cairo-tag-stack.c b/src/cairo-tag-stack.c
index ffe1e483a..0d32f4fab 100644
--- a/src/cairo-tag-stack.c
+++ b/src/cairo-tag-stack.c
@@ -198,7 +198,7 @@ _cairo_tag_stack_push (cairo_tag_stack_t *stack,
}
}
- elem = _cairo_malloc (sizeof(cairo_tag_stack_elem_t));
+ elem = _cairo_calloc (sizeof(cairo_tag_stack_elem_t));
if (unlikely (elem == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-tee-surface.c b/src/cairo-tee-surface.c
index 35baa9609..173991290 100644
--- a/src/cairo-tee-surface.c
+++ b/src/cairo-tee-surface.c
@@ -458,7 +458,7 @@ cairo_tee_surface_create (cairo_surface_t *primary)
if (unlikely (primary->status))
return _cairo_surface_create_in_error (primary->status);
- surface = _cairo_malloc (sizeof (cairo_tee_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_tee_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-tor-scan-converter.c b/src/cairo-tor-scan-converter.c
index e8142d5bc..f29359ce4 100644
--- a/src/cairo-tor-scan-converter.c
+++ b/src/cairo-tor-scan-converter.c
@@ -1872,7 +1872,7 @@ _cairo_tor_scan_converter_create (int xmin,
cairo_tor_scan_converter_t *self;
cairo_status_t status;
- self = _cairo_malloc (sizeof(struct _cairo_tor_scan_converter));
+ self = _cairo_calloc (sizeof(struct _cairo_tor_scan_converter));
if (unlikely (self == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail_nomem;
diff --git a/src/cairo-tor22-scan-converter.c b/src/cairo-tor22-scan-converter.c
index 1e71a35b4..bbdc02f3a 100644
--- a/src/cairo-tor22-scan-converter.c
+++ b/src/cairo-tor22-scan-converter.c
@@ -1675,7 +1675,7 @@ _cairo_tor22_scan_converter_create (int xmin,
cairo_tor22_scan_converter_t *self;
cairo_status_t status;
- self = _cairo_malloc (sizeof(struct _cairo_tor22_scan_converter));
+ self = _cairo_calloc (sizeof(struct _cairo_tor22_scan_converter));
if (unlikely (self == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail_nomem;
diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c
index 24cd1c4d7..211723c41 100644
--- a/src/cairo-toy-font-face.c
+++ b/src/cairo-toy-font-face.c
@@ -312,7 +312,7 @@ cairo_toy_font_face_create (const char *family,
}
/* Otherwise create it and insert into hash table. */
- font_face = _cairo_malloc (sizeof (cairo_toy_font_face_t));
+ font_face = _cairo_calloc (sizeof (cairo_toy_font_face_t));
if (unlikely (font_face == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto UNWIND_HASH_TABLE_LOCK;
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index e92bf11ac..a8551117c 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -194,7 +194,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
if (unlikely (status))
return status;
- font = _cairo_malloc (sizeof (cairo_truetype_font_t));
+ font = _cairo_calloc (sizeof (cairo_truetype_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-type3-glyph-surface.c b/src/cairo-type3-glyph-surface.c
index 53c029493..bb77756a1 100644
--- a/src/cairo-type3-glyph-surface.c
+++ b/src/cairo-type3-glyph-surface.c
@@ -82,7 +82,7 @@ _cairo_type3_glyph_surface_create (cairo_scaled_font_t *scaled_font,
if (unlikely (stream != NULL && stream->status))
return _cairo_surface_create_in_error (stream->status);
- surface = _cairo_malloc (sizeof (cairo_type3_glyph_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_type3_glyph_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index 37642cd1c..56525d5c1 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -573,7 +573,7 @@ _cairo_user_font_face_scaled_font_create (void *abstract_
font_face->immutable = TRUE;
- user_scaled_font = _cairo_malloc (sizeof (cairo_user_scaled_font_t));
+ user_scaled_font = _cairo_calloc (sizeof (cairo_user_scaled_font_t));
if (unlikely (user_scaled_font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -720,7 +720,7 @@ cairo_user_font_face_create (void)
{
cairo_user_font_face_t *font_face;
- font_face = _cairo_malloc (sizeof (cairo_user_font_face_t));
+ font_face = _cairo_calloc (sizeof (cairo_user_font_face_t));
if (!font_face) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_font_face_t *)&_cairo_font_face_nil;
diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 72d2b461a..213c920ac 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -111,7 +111,7 @@ _cairo_xcb_connection_find_visual_formats (cairo_xcb_connection_t *connection,
cairo_xcb_xrender_format_t *f;
cairo_status_t status;
- f = _cairo_malloc (sizeof (cairo_xcb_xrender_format_t));
+ f = _cairo_calloc (sizeof (cairo_xcb_xrender_format_t));
if (unlikely (f == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -177,7 +177,7 @@ _cairo_xcb_connection_parse_xrender_formats (cairo_xcb_connection_t *connection,
if (! _cairo_hash_table_lookup (connection->xrender_formats, &key)) {
cairo_xcb_xrender_format_t *f;
- f = _cairo_malloc (sizeof (cairo_xcb_xrender_format_t));
+ f = _cairo_calloc (sizeof (cairo_xcb_xrender_format_t));
if (unlikely (f == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -629,7 +629,7 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
}
}
- connection = _cairo_malloc (sizeof (cairo_xcb_connection_t));
+ connection = _cairo_calloc (sizeof (cairo_xcb_connection_t));
if (unlikely (connection == NULL))
goto unlock;
diff --git a/src/cairo-xcb-screen.c b/src/cairo-xcb-screen.c
index f443eec29..0ed880d66 100644
--- a/src/cairo-xcb-screen.c
+++ b/src/cairo-xcb-screen.c
@@ -249,7 +249,7 @@ _cairo_xcb_screen_get (xcb_connection_t *xcb_connection,
}
}
- screen = _cairo_malloc (sizeof (cairo_xcb_screen_t));
+ screen = _cairo_calloc (sizeof (cairo_xcb_screen_t));
if (unlikely (screen == NULL))
goto unlock;
diff --git a/src/cairo-xcb-shm.c b/src/cairo-xcb-shm.c
index 5bc64a6cf..4037eaa72 100644
--- a/src/cairo-xcb-shm.c
+++ b/src/cairo-xcb-shm.c
@@ -218,7 +218,7 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection,
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
- pool = _cairo_malloc (sizeof (cairo_xcb_shm_mem_pool_t));
+ pool = _cairo_calloc (sizeof (cairo_xcb_shm_mem_pool_t));
if (unlikely (pool == NULL)) {
CAIRO_MUTEX_UNLOCK (connection->shm_mutex);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-xcb-surface-core.c b/src/cairo-xcb-surface-core.c
index f9f12f04b..660e6d05a 100644
--- a/src/cairo-xcb-surface-core.c
+++ b/src/cairo-xcb-surface-core.c
@@ -85,7 +85,7 @@ _cairo_xcb_pixmap_create (cairo_xcb_surface_t *target,
{
cairo_xcb_pixmap_t *surface;
- surface = _cairo_malloc (sizeof (cairo_xcb_pixmap_t));
+ surface = _cairo_calloc (sizeof (cairo_xcb_pixmap_t));
if (unlikely (surface == NULL))
return (cairo_xcb_pixmap_t *)
_cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -119,7 +119,7 @@ _cairo_xcb_pixmap_copy (cairo_xcb_surface_t *target)
{
cairo_xcb_pixmap_t *surface;
- surface = _cairo_malloc (sizeof (cairo_xcb_pixmap_t));
+ surface = _cairo_calloc (sizeof (cairo_xcb_pixmap_t));
if (unlikely (surface == NULL))
return (cairo_xcb_pixmap_t *)
_cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index ab3d6881f..2777c3cda 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -114,7 +114,7 @@ _cairo_xcb_picture_create (cairo_xcb_screen_t *screen,
{
cairo_xcb_picture_t *surface;
- surface = _cairo_malloc (sizeof (cairo_xcb_picture_t));
+ surface = _cairo_calloc (sizeof (cairo_xcb_picture_t));
if (unlikely (surface == NULL))
return (cairo_xcb_picture_t *)
_cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -4136,7 +4136,7 @@ _cairo_xcb_font_create (cairo_xcb_connection_t *connection,
cairo_xcb_font_t *priv;
int i;
- priv = _cairo_malloc (sizeof (cairo_xcb_font_t));
+ priv = _cairo_calloc (sizeof (cairo_xcb_font_t));
if (unlikely (priv == NULL))
return NULL;
@@ -4329,7 +4329,7 @@ _cairo_xcb_glyph_fini (cairo_scaled_glyph_private_t *glyph_private,
}
if (to_free == NULL) {
- to_free = _cairo_malloc (sizeof (cairo_xcb_font_glyphset_free_glyphs_t));
+ to_free = _cairo_calloc (sizeof (cairo_xcb_font_glyphset_free_glyphs_t));
if (unlikely (to_free == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return; /* XXX cannot propagate failure */
@@ -4356,7 +4356,7 @@ _cairo_xcb_glyph_attach (cairo_xcb_connection_t *c,
{
cairo_xcb_glyph_private_t *priv;
- priv = _cairo_malloc (sizeof (*priv));
+ priv = _cairo_calloc (sizeof (*priv));
if (unlikely (priv == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 5e7ebef9e..302d3fbe0 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1069,7 +1069,7 @@ _cairo_xcb_surface_create_internal (cairo_xcb_screen_t *screen,
{
cairo_xcb_surface_t *surface;
- surface = _cairo_malloc (sizeof (cairo_xcb_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_xcb_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index 108897e92..8b2ffe8e1 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -207,7 +207,7 @@ _cairo_xlib_device_create (Display *dpy)
}
}
- display = _cairo_malloc (sizeof (cairo_xlib_display_t));
+ display = _cairo_calloc (sizeof (cairo_xlib_display_t));
if (unlikely (display == NULL)) {
device = _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
goto UNLOCK;
diff --git a/src/cairo-xlib-render-compositor.c b/src/cairo-xlib-render-compositor.c
index c872f5680..a870c00e1 100644
--- a/src/cairo-xlib-render-compositor.c
+++ b/src/cairo-xlib-render-compositor.c
@@ -989,7 +989,7 @@ _cairo_xlib_font_create (cairo_xlib_display_t *display,
cairo_xlib_font_t *priv;
int i;
- priv = _cairo_malloc (sizeof (cairo_xlib_font_t));
+ priv = _cairo_calloc (sizeof (cairo_xlib_font_t));
if (unlikely (priv == NULL))
return NULL;
@@ -1088,7 +1088,7 @@ _cairo_xlib_glyph_attach (cairo_xlib_display_t *display,
{
cairo_xlib_glyph_private_t *priv;
- priv = _cairo_malloc (sizeof (*priv));
+ priv = _cairo_calloc (sizeof (*priv));
if (unlikely (priv == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c
index ff3bdfcf9..cd8e2a75d 100644
--- a/src/cairo-xlib-screen.c
+++ b/src/cairo-xlib-screen.c
@@ -330,7 +330,7 @@ _cairo_xlib_screen_get (Display *dpy,
goto CLEANUP_DISPLAY;
}
- info = _cairo_malloc (sizeof (cairo_xlib_screen_t));
+ info = _cairo_calloc (sizeof (cairo_xlib_screen_t));
if (unlikely (info == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_DISPLAY;
diff --git a/src/cairo-xlib-source.c b/src/cairo-xlib-source.c
index 4c3b99d9e..69416d7d8 100644
--- a/src/cairo-xlib-source.c
+++ b/src/cairo-xlib-source.c
@@ -109,7 +109,7 @@ source (cairo_xlib_surface_t *dst, Picture picture, Pixmap pixmap)
if (picture == None)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
- source = _cairo_malloc (sizeof (*source));
+ source = _cairo_calloc (sizeof (*source));
if (unlikely (source == NULL)) {
XRenderFreePicture (dst->display->display, picture);
if (pixmap)
@@ -966,7 +966,7 @@ surface_source (cairo_xlib_surface_t *dst,
_cairo_xlib_shm_surface_get_pixmap (src)) {
cairo_xlib_proxy_t *proxy;
- proxy = _cairo_malloc (sizeof(*proxy));
+ proxy = _cairo_calloc (sizeof(*proxy));
if (unlikely (proxy == NULL))
return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-xlib-surface-shm.c b/src/cairo-xlib-surface-shm.c
index 10f947d9c..85a036938 100644
--- a/src/cairo-xlib-surface-shm.c
+++ b/src/cairo-xlib-surface-shm.c
@@ -576,7 +576,7 @@ _cairo_xlib_shm_pool_create(cairo_xlib_display_t *display,
size_t bytes, maxbits = 16, minbits = MIN_BITS;
Status success;
- pool = _cairo_malloc (sizeof (cairo_xlib_shm_t));
+ pool = _cairo_calloc (sizeof (cairo_xlib_shm_t));
if (pool == NULL)
return NULL;
@@ -653,7 +653,7 @@ _cairo_xlib_shm_info_create (cairo_xlib_display_t *display,
assert (mem != NULL);
- info = _cairo_malloc (sizeof (*info));
+ info = _cairo_calloc (sizeof (*info));
if (info == NULL) {
_cairo_mempool_free (&pool->mem, mem);
return NULL;
@@ -820,7 +820,7 @@ _cairo_xlib_shm_surface_create (cairo_xlib_surface_t *other,
if (size < MIN_SIZE)
return NULL;
- shm = _cairo_malloc (sizeof (*shm));
+ shm = _cairo_calloc (sizeof (*shm));
if (unlikely (shm == NULL))
return (cairo_xlib_shm_surface_t *)_cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
@@ -1393,7 +1393,7 @@ _cairo_xlib_display_init_shm (cairo_xlib_display_t *display)
if (!can_use_shm (display->display, &has_pixmap))
return;
- shm = _cairo_malloc (sizeof (*shm));
+ shm = _cairo_calloc (sizeof (*shm));
if (unlikely (shm == NULL))
return;
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 84d536209..fac291199 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -1773,7 +1773,7 @@ found:
;
}
- surface = _cairo_malloc (sizeof (cairo_xlib_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_xlib_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-xlib-visual.c b/src/cairo-xlib-visual.c
index 979cd5b36..055e441e4 100644
--- a/src/cairo-xlib-visual.c
+++ b/src/cairo-xlib-visual.c
@@ -82,7 +82,7 @@ _cairo_xlib_visual_info_create (Display *dpy,
for (i = 0; i < RAMP_SIZE; i++)
ramp_index_to_short[i] = (0xffff * i + ((RAMP_SIZE-1)>>1)) / (RAMP_SIZE-1);
- info = _cairo_malloc (sizeof (cairo_xlib_visual_info_t));
+ info = _cairo_calloc (sizeof (cairo_xlib_visual_info_t));
if (unlikely (info == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/test-compositor-surface.c b/src/test-compositor-surface.c
index d6e04a122..4518f509c 100644
--- a/src/test-compositor-surface.c
+++ b/src/test-compositor-surface.c
@@ -78,7 +78,7 @@ test_compositor_surface_create (const cairo_compositor_t *compositor,
if (unlikely (pixman_image == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
- surface = _cairo_malloc (sizeof (test_compositor_surface_t));
+ surface = _cairo_calloc (sizeof (test_compositor_surface_t));
if (unlikely (surface == NULL)) {
pixman_image_unref (pixman_image);
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/test-null-compositor-surface.c b/src/test-null-compositor-surface.c
index 35913a2b9..ad2a35968 100644
--- a/src/test-null-compositor-surface.c
+++ b/src/test-null-compositor-surface.c
@@ -81,7 +81,7 @@ test_compositor_surface_create (const cairo_compositor_t *compositor,
if (unlikely (pixman_image == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
- surface = _cairo_malloc (sizeof (test_compositor_surface_t));
+ surface = _cairo_calloc (sizeof (test_compositor_surface_t));
if (unlikely (surface == NULL)) {
pixman_image_unref (pixman_image);
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c
index 7967f7406..d33594d4b 100644
--- a/src/test-paginated-surface.c
+++ b/src/test-paginated-surface.c
@@ -74,7 +74,7 @@ _cairo_test_paginated_surface_create (cairo_surface_t *target)
if (unlikely (status))
return _cairo_surface_create_in_error (status);
- surface = _cairo_malloc (sizeof (test_paginated_surface_t));
+ surface = _cairo_calloc (sizeof (test_paginated_surface_t));
if (unlikely (surface == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/win32/cairo-dwrite-font.cpp b/src/win32/cairo-dwrite-font.cpp
index cf516d41c..b6931b367 100644
--- a/src/win32/cairo-dwrite-font.cpp
+++ b/src/win32/cairo-dwrite-font.cpp
@@ -639,7 +639,7 @@ _cairo_dwrite_font_face_scaled_font_create (void *abstract_face,
cairo_dwrite_font_face_t *font_face = static_cast<cairo_dwrite_font_face_t*>(abstract_face);
/* Must do malloc and not C++ new, since Cairo frees this. */
- cairo_dwrite_scaled_font_t *dwrite_font = (cairo_dwrite_scaled_font_t*)_cairo_malloc(
+ cairo_dwrite_scaled_font_t *dwrite_font = (cairo_dwrite_scaled_font_t*)_cairo_calloc(
sizeof(cairo_dwrite_scaled_font_t));
if (unlikely(dwrite_font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/win32/cairo-win32-device.c b/src/win32/cairo-win32-device.c
index 6032ce7d9..e000b11f6 100644
--- a/src/win32/cairo-win32-device.c
+++ b/src/win32/cairo-win32-device.c
@@ -127,7 +127,7 @@ _cairo_win32_device_get (void)
if (__cairo_win32_device)
return cairo_device_reference (__cairo_win32_device);
- device = _cairo_malloc (sizeof (*device));
+ device = _cairo_calloc (sizeof (*device));
_cairo_device_init (&device->base, &_cairo_win32_device_backend);
diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
index e3b3eec2f..2800052bc 100644
--- a/src/win32/cairo-win32-display-surface.c
+++ b/src/win32/cairo-win32-display-surface.c
@@ -295,7 +295,7 @@ _cairo_win32_display_surface_create_for_dc (HDC original_dc,
unsigned char *bits;
int rowstride;
- surface = _cairo_malloc (sizeof (*surface));
+ surface = _cairo_calloc (sizeof (*surface));
if (surface == NULL)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
@@ -992,7 +992,7 @@ cairo_win32_surface_create_with_format (HDC hdc, cairo_format_t format)
break;
}
- surface = _cairo_malloc (sizeof (*surface));
+ surface = _cairo_calloc (sizeof (*surface));
if (surface == NULL)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
index a561e74a4..3ad4f7ff4 100644
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -333,7 +333,7 @@ _win32_scaled_font_create (LOGFONTW *logfont,
if (hdc == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- f = _cairo_malloc (sizeof(cairo_win32_scaled_font_t));
+ f = _cairo_calloc (sizeof(cairo_win32_scaled_font_t));
if (f == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1868,7 +1868,7 @@ cairo_win32_font_face_create_for_logfontw_hfont (LOGFONTW *logfont, HFONT font)
}
/* Otherwise create it and insert into hash table. */
- font_face = _cairo_malloc (sizeof (cairo_win32_font_face_t));
+ font_face = _cairo_calloc (sizeof (cairo_win32_font_face_t));
if (!font_face) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
goto FAIL;
diff --git a/src/win32/cairo-win32-printing-surface.c b/src/win32/cairo-win32-printing-surface.c
index aa07a80b7..8305ede9c 100644
--- a/src/win32/cairo-win32-printing-surface.c
+++ b/src/win32/cairo-win32-printing-surface.c
@@ -1524,7 +1524,7 @@ _cairo_win32_printing_surface_stroke (void *abstract_surface,
dash_array = NULL;
if (style->num_dashes) {
pen_style |= PS_USERSTYLE;
- dash_array = _cairo_calloc (sizeof (DWORD), style->num_dashes);
+ dash_array = _cairo_calloc_ab (sizeof (DWORD), style->num_dashes);
for (i = 0; i < style->num_dashes; i++) {
dash_array[i] = (DWORD) (scale * style->dash[i]);
}
@@ -2167,7 +2167,7 @@ cairo_win32_printing_surface_create (HDC hdc)
cairo_win32_printing_surface_t *surface;
cairo_surface_t *paginated;
- surface = _cairo_malloc (sizeof (cairo_win32_printing_surface_t));
+ surface = _cairo_calloc (sizeof (cairo_win32_printing_surface_t));
if (surface == NULL)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
commit 8da24bf7fb426da97df1c390a216db2c192862a5
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Fri Jun 21 08:53:01 2024 +0930
Make _cairo_calloc() consistent with _cairo_malloc()
ie
_cairo_calloc(size)
_cairo_calloc_ab(a, size)
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 6cc2ab4f5..39a30dff0 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -952,7 +952,7 @@ cairo_cff_font_read_private_dict (cairo_cff_font_t *font,
decode_number (operand, nominal_width);
num_subs = _cairo_array_num_elements (local_sub_index);
- *local_subs_used = _cairo_calloc (num_subs, sizeof (cairo_bool_t));
+ *local_subs_used = _cairo_calloc_ab (num_subs, sizeof (cairo_bool_t));
if (unlikely (*local_subs_used == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -971,7 +971,7 @@ cairo_cff_font_read_fdselect (cairo_cff_font_t *font, unsigned char *p)
{
int type, num_ranges, first, last, fd, i, j;
- font->fdselect = _cairo_calloc (font->num_glyphs, sizeof (int));
+ font->fdselect = _cairo_calloc_ab (font->num_glyphs, sizeof (int));
if (unlikely (font->fdselect == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1021,43 +1021,43 @@ cairo_cff_font_read_cid_fontdict (cairo_cff_font_t *font, unsigned char *ptr)
font->num_fontdicts = _cairo_array_num_elements (&index);
- font->fd_dict = _cairo_calloc (font->num_fontdicts, sizeof (cairo_hash_table_t *));
+ font->fd_dict = _cairo_calloc_ab (font->num_fontdicts, sizeof (cairo_hash_table_t *));
if (unlikely (font->fd_dict == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_private_dict = _cairo_calloc (font->num_fontdicts, sizeof (cairo_hash_table_t *));
+ font->fd_private_dict = _cairo_calloc_ab (font->num_fontdicts, sizeof (cairo_hash_table_t *));
if (unlikely (font->fd_private_dict == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_local_sub_index = _cairo_calloc (font->num_fontdicts, sizeof (cairo_array_t));
+ font->fd_local_sub_index = _cairo_calloc_ab (font->num_fontdicts, sizeof (cairo_array_t));
if (unlikely (font->fd_local_sub_index == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_local_sub_bias = _cairo_calloc (font->num_fontdicts, sizeof (int));
+ font->fd_local_sub_bias = _cairo_calloc_ab (font->num_fontdicts, sizeof (int));
if (unlikely (font->fd_local_sub_bias == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_local_subs_used = _cairo_calloc (font->num_fontdicts, sizeof (cairo_bool_t *));
+ font->fd_local_subs_used = _cairo_calloc_ab (font->num_fontdicts, sizeof (cairo_bool_t *));
if (unlikely (font->fd_local_subs_used == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_default_width = _cairo_calloc (font->num_fontdicts, sizeof (double));
+ font->fd_default_width = _cairo_calloc_ab (font->num_fontdicts, sizeof (double));
if (unlikely (font->fd_default_width == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
}
- font->fd_nominal_width = _cairo_calloc (font->num_fontdicts, sizeof (double));
+ font->fd_nominal_width = _cairo_calloc_ab (font->num_fontdicts, sizeof (double));
if (unlikely (font->fd_nominal_width == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
@@ -1315,7 +1315,7 @@ cairo_cff_font_read_global_subroutines (cairo_cff_font_t *font)
num_subs = _cairo_array_num_elements (&font->global_sub_index);
if (num_subs > 0) {
- font->global_subs_used = _cairo_calloc (num_subs, sizeof(cairo_bool_t));
+ font->global_subs_used = _cairo_calloc_ab (num_subs, sizeof(cairo_bool_t));
if (unlikely (font->global_subs_used == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
} else {
@@ -1836,20 +1836,20 @@ cairo_cff_font_subset_fontdict (cairo_cff_font_t *font)
unsigned long cid, gid;
cairo_int_status_t status;
- font->fdselect_subset = _cairo_calloc (font->scaled_font_subset->num_glyphs,
+ font->fdselect_subset = _cairo_calloc_ab (font->scaled_font_subset->num_glyphs,
sizeof (int));
if (unlikely (font->fdselect_subset == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- font->fd_subset_map = _cairo_calloc (font->num_fontdicts, sizeof (int));
+ font->fd_subset_map = _cairo_calloc_ab (font->num_fontdicts, sizeof (int));
if (unlikely (font->fd_subset_map == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- font->private_dict_offset = _cairo_calloc (font->num_fontdicts, sizeof (int));
+ font->private_dict_offset = _cairo_calloc_ab (font->num_fontdicts, sizeof (int));
if (unlikely (font->private_dict_offset == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- reverse_map = _cairo_calloc (font->num_fontdicts, sizeof (int));
+ reverse_map = _cairo_calloc_ab (font->num_fontdicts, sizeof (int));
if (unlikely (reverse_map == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2814,7 +2814,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
return CAIRO_INT_STATUS_UNSUPPORTED;
}
- font = _cairo_calloc (1, sizeof (cairo_cff_font_t));
+ font = _cairo_calloc (sizeof (cairo_cff_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2839,7 +2839,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
goto fail2;
}
- font->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
+ font->widths = _cairo_calloc_ab (font->scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@@ -2998,7 +2998,8 @@ _cairo_cff_subset_init (cairo_cff_subset_t *cff_subset,
cff_subset->family_name_utf8 = NULL;
}
- cff_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
+ cff_subset->widths = _cairo_calloc_ab (font->scaled_font_subset->num_glyphs,
+ sizeof (double));
if (unlikely (cff_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@@ -3164,7 +3165,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
cairo_status_t status;
cairo_cff_font_t *font;
- font = _cairo_calloc (1, sizeof (cairo_cff_font_t));
+ font = _cairo_calloc (sizeof (cairo_cff_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -3196,7 +3197,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
font->ascent = 0;
font->descent = 0;
- font->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
+ font->widths = _cairo_calloc_ab (font->scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@@ -3411,7 +3412,7 @@ _cairo_cff_fallback_init (cairo_cff_subset_t *cff_subset,
goto fail2;
}
- cff_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
+ cff_subset->widths = _cairo_calloc_ab (font->scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (cff_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
diff --git a/src/cairo-clip-tor-scan-converter.c b/src/cairo-clip-tor-scan-converter.c
index f347c764e..be91aa3a0 100644
--- a/src/cairo-clip-tor-scan-converter.c
+++ b/src/cairo-clip-tor-scan-converter.c
@@ -1794,7 +1794,7 @@ _cairo_clip_tor_scan_converter_create (cairo_clip_t *clip,
cairo_status_t status;
int i;
- self = _cairo_calloc (1, sizeof(struct _cairo_clip_tor_scan_converter));
+ self = _cairo_calloc (sizeof(struct _cairo_clip_tor_scan_converter));
if (unlikely (self == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail_nomem;
diff --git a/src/cairo-colr-glyph-render.c b/src/cairo-colr-glyph-render.c
index 05e3da29d..d28e0ba16 100644
--- a/src/cairo-colr-glyph-render.c
+++ b/src/cairo-colr-glyph-render.c
@@ -327,12 +327,12 @@ read_colorline (cairo_colr_glyph_render_t *render,
double colr_alpha;
cairo_bool_t is_foreground_color;
- cl = _cairo_calloc (1, sizeof (cairo_colr_color_line_t));
+ cl = _cairo_calloc (sizeof (cairo_colr_color_line_t));
if (unlikely (cl == NULL))
return NULL;
cl->n_stops = colorline->color_stop_iterator.num_color_stops;
- cl->stops = _cairo_calloc (cl->n_stops, sizeof (cairo_colr_color_stop_t));
+ cl->stops = _cairo_calloc_ab (cl->n_stops, sizeof (cairo_colr_color_stop_t));
if (unlikely (cl->stops == NULL)) {
free (cl);
return NULL;
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index d325cc8a6..d34db4ceb 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -470,7 +470,7 @@ _cairo_ft_unscaled_font_init (cairo_ft_unscaled_font_t *unscaled,
unscaled->have_color = FT_HAS_COLOR (face) != 0;
unscaled->have_color_set = TRUE;
if (FT_Get_MM_Var (face, &ft_mm_var) == 0) {
- unscaled->variations = _cairo_calloc (ft_mm_var->num_axis, sizeof (FT_Fixed));
+ unscaled->variations = _cairo_calloc_ab (ft_mm_var->num_axis, sizeof (FT_Fixed));
if (unscaled->variations)
FT_Get_Var_Design_Coordinates (face, ft_mm_var->num_axis, unscaled->variations);
FT_Done_MM_Var (face->glyph->library, ft_mm_var);
@@ -1554,7 +1554,7 @@ _render_glyph_outline (FT_Face face,
if (bitmap_size < 0)
return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
- bitmap.buffer = _cairo_calloc (1, bitmap_size);
+ bitmap.buffer = _cairo_calloc (bitmap_size);
if (bitmap.buffer == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-hash.c b/src/cairo-hash.c
index 8a6772506..5bda8fac8 100644
--- a/src/cairo-hash.c
+++ b/src/cairo-hash.c
@@ -178,7 +178,7 @@ _cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal)
memset (&hash_table->cache, 0, sizeof (hash_table->cache));
hash_table->table_size = &hash_table_sizes[0];
- hash_table->entries = _cairo_calloc (*hash_table->table_size,
+ hash_table->entries = _cairo_calloc_ab (*hash_table->table_size,
sizeof (cairo_hash_entry_t *));
if (unlikely (hash_table->entries == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
@@ -304,7 +304,7 @@ _cairo_hash_table_manage (cairo_hash_table_t *hash_table)
}
new_size = *tmp.table_size;
- tmp.entries = _cairo_calloc (new_size, sizeof (cairo_hash_entry_t*));
+ tmp.entries = _cairo_calloc_ab (new_size, sizeof (cairo_hash_entry_t*));
if (unlikely (tmp.entries == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-malloc-private.h b/src/cairo-malloc-private.h
index f7c1ac914..b850c475c 100644
--- a/src/cairo-malloc-private.h
+++ b/src/cairo-malloc-private.h
@@ -64,10 +64,10 @@
/**
* _cairo_calloc:
- * @a: number of elements to allocate
* @size: size of each element
*
- * Allocates @a*@size memory using calloc().
+ * Allocates @size memory using calloc(). Behaves much like
+ * calloc(), except that only one parameter is required.
* The memory should be freed using free().
* calloc is skipped, if 0 bytes are requested, and %NULL will be returned.
*
@@ -75,8 +75,8 @@
* case of calloc() failure or overflow.
**/
-#define _cairo_calloc(a, size) \
- ((((a) != 0) && ((size) != 0)) ? calloc(a, size) : NULL)
+#define _cairo_calloc(size) \
+ ((size) != 0 ? calloc(1,size) : NULL)
/**
* _cairo_malloc_ab:
@@ -105,6 +105,31 @@ _cairo_malloc_ab(size_t a, size_t size)
return _cairo_malloc(c);
}
+/**
+ * _cairo_calloc_ab:
+ * @a: number of elements to allocate
+ * @size: size of each element
+ *
+ * Allocates @a*@size memory using _cairo_calloc(), taking care to not
+ * overflow when doing the multiplication.
+ *
+ * @size should be a constant so that the compiler can optimize
+ * out a constant division.
+ *
+ * Return value: A pointer to the newly allocated memory, or %NULL in
+ * case of calloc() failure or overflow.
+ **/
+
+static cairo_always_inline void *
+_cairo_calloc_ab(size_t a, size_t size)
+{
+ size_t c;
+ if (_cairo_mul_size_t_overflow (a, size, &c))
+ return NULL;
+
+ return _cairo_calloc(c);
+}
+
/**
* _cairo_realloc_ab:
* @ptr: original pointer to block of memory to be resized
diff --git a/src/cairo-mempool.c b/src/cairo-mempool.c
index 04077edcb..6cebaf123 100644
--- a/src/cairo-mempool.c
+++ b/src/cairo-mempool.c
@@ -305,7 +305,7 @@ _cairo_mempool_init (cairo_mempool_t *pool,
pool->max_free_bits = -1;
num_blocks = bytes >> min_bits;
- pool->blocks = _cairo_calloc (num_blocks, sizeof (struct _cairo_memblock));
+ pool->blocks = _cairo_calloc_ab (num_blocks, sizeof (struct _cairo_memblock));
if (pool->blocks == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-pdf-interchange.c b/src/cairo-pdf-interchange.c
index eeb3392ca..c0db4531f 100644
--- a/src/cairo-pdf-interchange.c
+++ b/src/cairo-pdf-interchange.c
@@ -1583,7 +1583,7 @@ _cairo_pdf_interchange_write_document_dests (cairo_pdf_surface_t *surface)
return CAIRO_STATUS_SUCCESS;
}
- ic->sorted_dests = _cairo_calloc (ic->num_dests, sizeof (cairo_pdf_named_dest_t *));
+ ic->sorted_dests = _cairo_calloc_ab (ic->num_dests, sizeof (cairo_pdf_named_dest_t *));
if (unlikely (ic->sorted_dests == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1838,7 +1838,7 @@ _cairo_pdf_interchange_begin_dest_tag (cairo_pdf_surface_t *surface,
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) {
- dest = _cairo_calloc (1, sizeof (cairo_pdf_named_dest_t));
+ dest = _cairo_calloc (sizeof (cairo_pdf_named_dest_t));
if (unlikely (dest == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2439,7 +2439,7 @@ _cairo_pdf_interchange_init (cairo_pdf_surface_t *surface)
_cairo_tag_stack_init (&ic->analysis_tag_stack);
_cairo_tag_stack_init (&ic->render_tag_stack);
- ic->struct_root = _cairo_calloc (1, sizeof(cairo_pdf_struct_tree_node_t));
+ ic->struct_root = _cairo_calloc (sizeof(cairo_pdf_struct_tree_node_t));
if (unlikely (ic->struct_root == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -2483,7 +2483,7 @@ _cairo_pdf_interchange_init (cairo_pdf_surface_t *surface)
ic->mcid_order = 0;
_cairo_array_init (&ic->outline, sizeof(cairo_pdf_outline_entry_t *));
- outline_root = _cairo_calloc (1, sizeof(cairo_pdf_outline_entry_t));
+ outline_root = _cairo_calloc (sizeof(cairo_pdf_outline_entry_t));
if (unlikely (outline_root == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 26a1575da..0ae8745ac 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1402,7 +1402,7 @@ _cairo_pdf_surface_create_smask_group (cairo_pdf_surface_t *surface,
{
cairo_pdf_smask_group_t *group;
- group = _cairo_calloc (1, sizeof (cairo_pdf_smask_group_t));
+ group = _cairo_calloc (sizeof (cairo_pdf_smask_group_t));
if (unlikely (group == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index b08955092..30a5c908f 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -3521,7 +3521,7 @@ _cairo_ps_surface_use_form (cairo_ps_surface_t *surface,
unique_id_length = source_key.unique_id_length;
memcpy (unique_id, source_key.unique_id, unique_id_length);
- source_entry = _cairo_calloc (1, sizeof (cairo_ps_form_t));
+ source_entry = _cairo_calloc (sizeof (cairo_ps_form_t));
if (source_entry == NULL) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
diff --git a/src/cairo-raster-source-pattern.c b/src/cairo-raster-source-pattern.c
index e657e5c61..0ae3b946a 100644
--- a/src/cairo-raster-source-pattern.c
+++ b/src/cairo-raster-source-pattern.c
@@ -168,7 +168,7 @@ cairo_pattern_create_raster_source (void *user_data,
if (! CAIRO_CONTENT_VALID (content))
return _cairo_pattern_create_in_error (CAIRO_STATUS_INVALID_CONTENT);
- pattern = _cairo_calloc (1, sizeof (*pattern));
+ pattern = _cairo_calloc (sizeof (*pattern));
if (unlikely (pattern == NULL))
return _cairo_pattern_create_in_error (CAIRO_STATUS_NO_MEMORY);
diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c
index 59428c8a4..92efd6bbe 100644
--- a/src/cairo-recording-surface.c
+++ b/src/cairo-recording-surface.c
@@ -1197,7 +1197,7 @@ _cairo_recording_surface_tag (void *abstract_surface,
surface->has_tags = TRUE;
- command = _cairo_calloc (1, sizeof (cairo_command_tag_t));
+ command = _cairo_calloc (sizeof (cairo_command_tag_t));
if (unlikely (command == NULL)) {
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -1520,7 +1520,7 @@ _cairo_recording_surface_copy__tag (cairo_recording_surface_t *surface,
cairo_command_tag_t *command;
cairo_status_t status;
- command = _cairo_calloc (1, sizeof (*command));
+ command = _cairo_calloc (sizeof (*command));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err;
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index e573c530b..ed898d405 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -1238,7 +1238,7 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
if (unlikely (names == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- subset->glyph_names = _cairo_calloc (subset->num_glyphs, sizeof (char *));
+ subset->glyph_names = _cairo_calloc_ab (subset->num_glyphs, sizeof (char *));
if (unlikely (subset->glyph_names == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_HASH;
diff --git a/src/cairo-tag-attributes.c b/src/cairo-tag-attributes.c
index 8c305e3cc..70ccd674f 100644
--- a/src/cairo-tag-attributes.c
+++ b/src/cairo-tag-attributes.c
@@ -432,7 +432,7 @@ parse_attributes (const char *attributes, const attribute_spec_t *attrib_def, ca
goto fail1;
}
- attrib = _cairo_calloc (1, sizeof (attribute_t));
+ attrib = _cairo_calloc (sizeof (attribute_t));
if (unlikely (attrib == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 7f9a075aa..e92bf11ac 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -212,14 +212,14 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
/* Add 2: +1 case font does not contain .notdef, and +1 because an extra
* entry is required to contain the end location of the last glyph.
*/
- font->glyphs = _cairo_calloc (font->base.num_glyphs_in_face + 2, sizeof (subset_glyph_t));
+ font->glyphs = _cairo_calloc_ab (font->base.num_glyphs_in_face + 2, sizeof (subset_glyph_t));
if (unlikely (font->glyphs == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
}
/* Add 1 in case font does not contain .notdef */
- font->parent_to_subset = _cairo_calloc (font->base.num_glyphs_in_face + 1, sizeof (int));
+ font->parent_to_subset = _cairo_calloc_ab (font->base.num_glyphs_in_face + 1, sizeof (int));
if (unlikely (font->parent_to_subset == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
@@ -259,7 +259,7 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
}
/* Add 1 in case font does not contain .notdef */
- font->widths = _cairo_calloc (font->base.num_glyphs_in_face + 1, sizeof (int));
+ font->widths = _cairo_calloc_ab (font->base.num_glyphs_in_face + 1, sizeof (int));
if (unlikely (font->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail4;
@@ -1181,7 +1181,8 @@ cairo_truetype_subset_init_internal (cairo_truetype_subset_t *truetype_subse
/* The widths array returned must contain only widths for the
* glyphs in font_subset. Any subglyphs appended after
* font_subset->num_glyphs are omitted. */
- truetype_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
+ truetype_subset->widths = _cairo_calloc_ab (font->scaled_font_subset->num_glyphs,
+ sizeof (double));
if (unlikely (truetype_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index 3abcd7e19..d0bbc62f0 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -88,11 +88,11 @@ cairo_type1_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
cairo_font_options_t font_options;
cairo_status_t status;
- font = _cairo_calloc (1, sizeof (cairo_type1_font_t));
+ font = _cairo_calloc (sizeof (cairo_type1_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- font->widths = _cairo_calloc (scaled_font_subset->num_glyphs, sizeof (int));
+ font->widths = _cairo_calloc_ab (scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
free (font);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -747,7 +747,8 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t *type1_subset,
goto fail1;
}
- type1_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
+ type1_subset->widths = _cairo_calloc_ab (font->scaled_font_subset->num_glyphs,
+ sizeof (double));
if (unlikely (type1_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail2;
@@ -841,7 +842,7 @@ _cairo_type2_charstrings_init (cairo_type2_charstrings_t *type2_subset,
_cairo_array_init (&type2_subset->charstrings, sizeof (cairo_array_t));
- type2_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
+ type2_subset->widths = _cairo_calloc_ab (font->scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (type2_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index fad6144bd..5c3766e3a 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -167,7 +167,8 @@ _cairo_type1_font_subset_init (cairo_type1_font_subset_t *font,
_cairo_array_init (&font->glyphs_array, sizeof (glyph_data_t));
_cairo_array_init (&font->glyph_names_array, sizeof (char *));
- font->scaled_subset_index_to_glyphs = _cairo_calloc (scaled_font_subset->num_glyphs, sizeof font->scaled_subset_index_to_glyphs[0]);
+ font->scaled_subset_index_to_glyphs = _cairo_calloc_ab (scaled_font_subset->num_glyphs,
+ sizeof font->scaled_subset_index_to_glyphs[0]);
if (unlikely (font->scaled_subset_index_to_glyphs == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1355,7 +1356,7 @@ cairo_type1_font_subset_write_private_dict (cairo_type1_font_subset_t *font,
if (font->num_subrs <= 0)
return CAIRO_INT_STATUS_UNSUPPORTED;
- font->subrs = _cairo_calloc (font->num_subrs, sizeof (font->subrs[0]));
+ font->subrs = _cairo_calloc_ab (font->num_subrs, sizeof (font->subrs[0]));
if (unlikely (font->subrs == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1410,7 +1411,8 @@ skip_subrs:
font->glyphs = _cairo_array_index (&font->glyphs_array, 0);
font->glyph_names = _cairo_array_index (&font->glyph_names_array, 0);
font->base.num_glyphs = _cairo_array_num_elements (&font->glyphs_array);
- font->type1_subset_index_to_glyphs = _cairo_calloc (font->base.num_glyphs, sizeof font->type1_subset_index_to_glyphs[0]);
+ font->type1_subset_index_to_glyphs = _cairo_calloc_ab (font->base.num_glyphs,
+ sizeof font->type1_subset_index_to_glyphs[0]);
if (unlikely (font->type1_subset_index_to_glyphs == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -1782,7 +1784,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset,
if (unlikely (type1_subset->base_font == NULL))
goto fail1;
- type1_subset->widths = _cairo_calloc (scaled_font_subset->num_glyphs, sizeof (double));
+ type1_subset->widths = _cairo_calloc_ab (scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (type1_subset->widths == NULL))
goto fail2;
diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 3f1f04508..72d2b461a 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -686,7 +686,8 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
connection->root = xcb_get_setup (xcb_connection);
connection->render = NULL;
- connection->subpixel_orders = _cairo_calloc (connection->root->roots_len, sizeof(*connection->subpixel_orders));
+ connection->subpixel_orders = _cairo_calloc_ab (connection->root->roots_len,
+ sizeof(*connection->subpixel_orders));
if (unlikely (connection->subpixel_orders == NULL)) {
CAIRO_MUTEX_UNLOCK (connection->device.mutex);
_cairo_xcb_connection_destroy (connection);
More information about the cairo-commit
mailing list