Merge branch 'calloc' into 'master'

Use calloc to allocate structs

See merge request cairo/cairo!566
This commit is contained in:
Adrian Johnson 2024-06-24 08:46:51 +00:00
commit b807b7a87a
76 changed files with 251 additions and 220 deletions

View file

@ -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));
}

View file

@ -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;

View file

@ -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;

View file

@ -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);
@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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));
}

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);
@ -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);
@ -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;
@ -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);
@ -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;

View file

@ -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

View file

@ -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;
@ -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);

View file

@ -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));

View file

@ -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));

View file

@ -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

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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);
@ -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);
@ -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);
@ -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);
@ -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);

View file

@ -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;

View file

@ -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);
@ -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;
@ -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));

View file

@ -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;
@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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));

View file

@ -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);

View file

@ -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;
@ -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);
}
@ -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;
@ -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;
@ -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);

View file

@ -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;

View file

@ -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);
@ -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;

View file

@ -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);

View file

@ -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));

View file

@ -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);

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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);

View file

@ -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);
}

View file

@ -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;

View file

@ -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);

View file

@ -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));

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);
@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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));

View file

@ -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;

View file

@ -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;
@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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));

View file

@ -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);

View file

@ -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));

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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));

View file

@ -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);

View file

@ -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));

View file

@ -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));

View file

@ -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));

View file

@ -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);

View file

@ -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);

View file

@ -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));

View file

@ -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;

View file

@ -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));