Create _cairo_calloc() macro to replace calloc()

Not all platforms handle a zero sized allocation in calloc the
same. This macro ensures that _cairo_calloc(0) always returns NULL
similar to _cairo_malloc(0).
This commit is contained in:
Adrian Johnson 2024-05-21 20:13:59 +09:30
parent 3d46485365
commit 3715d93bdf
19 changed files with 69 additions and 53 deletions

View file

@ -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 = calloc (num_subs, sizeof (cairo_bool_t));
*local_subs_used = _cairo_calloc (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 = calloc (font->num_glyphs, sizeof (int));
font->fdselect = _cairo_calloc (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 = calloc (font->num_fontdicts, sizeof (cairo_hash_table_t *));
font->fd_dict = _cairo_calloc (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 = calloc (font->num_fontdicts, sizeof (cairo_hash_table_t *));
font->fd_private_dict = _cairo_calloc (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 = calloc (font->num_fontdicts, sizeof (cairo_array_t));
font->fd_local_sub_index = _cairo_calloc (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 = calloc (font->num_fontdicts, sizeof (int));
font->fd_local_sub_bias = _cairo_calloc (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 = calloc (font->num_fontdicts, sizeof (cairo_bool_t *));
font->fd_local_subs_used = _cairo_calloc (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 = calloc (font->num_fontdicts, sizeof (double));
font->fd_default_width = _cairo_calloc (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 = calloc (font->num_fontdicts, sizeof (double));
font->fd_nominal_width = _cairo_calloc (font->num_fontdicts, sizeof (double));
if (unlikely (font->fd_nominal_width == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;
@ -1314,7 +1314,7 @@ cairo_cff_font_read_global_subroutines (cairo_cff_font_t *font)
return status;
num_subs = _cairo_array_num_elements (&font->global_sub_index);
font->global_subs_used = calloc (num_subs, sizeof(cairo_bool_t));
font->global_subs_used = _cairo_calloc (num_subs, sizeof(cairo_bool_t));
if (unlikely (font->global_subs_used == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -1832,20 +1832,20 @@ cairo_cff_font_subset_fontdict (cairo_cff_font_t *font)
unsigned long cid, gid;
cairo_int_status_t status;
font->fdselect_subset = calloc (font->scaled_font_subset->num_glyphs,
font->fdselect_subset = _cairo_calloc (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 = calloc (font->num_fontdicts, sizeof (int));
font->fd_subset_map = _cairo_calloc (font->num_fontdicts, sizeof (int));
if (unlikely (font->fd_subset_map == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->private_dict_offset = calloc (font->num_fontdicts, sizeof (int));
font->private_dict_offset = _cairo_calloc (font->num_fontdicts, sizeof (int));
if (unlikely (font->private_dict_offset == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
reverse_map = calloc (font->num_fontdicts, sizeof (int));
reverse_map = _cairo_calloc (font->num_fontdicts, sizeof (int));
if (unlikely (reverse_map == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -2810,7 +2810,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
return CAIRO_INT_STATUS_UNSUPPORTED;
}
font = calloc (1, sizeof (cairo_cff_font_t));
font = _cairo_calloc (1, sizeof (cairo_cff_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -2835,7 +2835,7 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
goto fail2;
}
font->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
font->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@ -2994,7 +2994,7 @@ _cairo_cff_subset_init (cairo_cff_subset_t *cff_subset,
cff_subset->family_name_utf8 = NULL;
}
cff_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
cff_subset->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (cff_subset->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@ -3160,7 +3160,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
cairo_status_t status;
cairo_cff_font_t *font;
font = calloc (1, sizeof (cairo_cff_font_t));
font = _cairo_calloc (1, sizeof (cairo_cff_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -3192,7 +3192,7 @@ _cairo_cff_font_fallback_create (cairo_scaled_font_subset_t *scaled_font_subset
font->ascent = 0;
font->descent = 0;
font->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
font->widths = _cairo_calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail3;
@ -3407,7 +3407,7 @@ _cairo_cff_fallback_init (cairo_cff_subset_t *cff_subset,
goto fail2;
}
cff_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
cff_subset->widths = _cairo_calloc (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 = calloc (1, sizeof(struct _cairo_clip_tor_scan_converter));
self = _cairo_calloc (1, sizeof(struct _cairo_clip_tor_scan_converter));
if (unlikely (self == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto bail_nomem;

View file

@ -327,12 +327,12 @@ read_colorline (cairo_colr_glyph_render_t *render,
double colr_alpha;
cairo_bool_t is_foreground_color;
cl = calloc (1, sizeof (cairo_colr_color_line_t));
cl = _cairo_calloc (1, sizeof (cairo_colr_color_line_t));
if (unlikely (cl == NULL))
return NULL;
cl->n_stops = colorline->color_stop_iterator.num_color_stops;
cl->stops = calloc (cl->n_stops, sizeof (cairo_colr_color_stop_t));
cl->stops = _cairo_calloc (cl->n_stops, sizeof (cairo_colr_color_stop_t));
if (unlikely (cl->stops == NULL)) {
free (cl);
return NULL;

View file

@ -499,7 +499,7 @@ _cairo_ft_unscaled_font_init (cairo_ft_unscaled_font_t *unscaled,
FT_MM_Var *ft_mm_var;
if (0 == FT_Get_MM_Var (face, &ft_mm_var))
{
unscaled->variations = calloc (ft_mm_var->num_axis, sizeof (FT_Fixed));
unscaled->variations = _cairo_calloc (ft_mm_var->num_axis, sizeof (FT_Fixed));
if (unscaled->variations)
FT_Get_Var_Design_Coordinates (face, ft_mm_var->num_axis, unscaled->variations);
#if HAVE_FT_DONE_MM_VAR
@ -1601,7 +1601,7 @@ _render_glyph_outline (FT_Face face,
if (bitmap_size < 0)
return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
bitmap.buffer = calloc (1, bitmap_size);
bitmap.buffer = _cairo_calloc (1, bitmap_size);
if (bitmap.buffer == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

View file

@ -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 = calloc (*hash_table->table_size,
hash_table->entries = _cairo_calloc (*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 = calloc (new_size, sizeof (cairo_hash_entry_t*));
tmp.entries = _cairo_calloc (new_size, sizeof (cairo_hash_entry_t*));
if (unlikely (tmp.entries == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

View file

@ -62,6 +62,22 @@
#define _cairo_malloc(size) \
((size) != 0 ? malloc(size) : NULL)
/**
* _cairo_calloc:
* @a: number of elements to allocate
* @size: size of each element
*
* Allocates @a*@size memory using calloc().
* The memory should be freed using free().
* calloc is skipped, if 0 bytes are requested, and %NULL will be returned.
*
* Return value: A pointer to the newly allocated memory, or %NULL in
* case of calloc() failure or overflow.
**/
#define _cairo_calloc(a, size) \
((((a) != 0) && ((size) != 0)) ? calloc(a, size) : NULL)
/**
* _cairo_malloc_ab:
* @a: number of elements to allocate

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 = calloc (num_blocks, sizeof (struct _cairo_memblock));
pool->blocks = _cairo_calloc (num_blocks, sizeof (struct _cairo_memblock));
if (pool->blocks == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

View file

@ -1583,7 +1583,7 @@ _cairo_pdf_interchange_write_document_dests (cairo_pdf_surface_t *surface)
return CAIRO_STATUS_SUCCESS;
}
ic->sorted_dests = calloc (ic->num_dests, sizeof (cairo_pdf_named_dest_t *));
ic->sorted_dests = _cairo_calloc (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 = calloc (1, sizeof (cairo_pdf_named_dest_t));
dest = _cairo_calloc (1, sizeof (cairo_pdf_named_dest_t));
if (unlikely (dest == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -2431,7 +2431,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 = calloc (1, sizeof(cairo_pdf_struct_tree_node_t));
ic->struct_root = _cairo_calloc (1, sizeof(cairo_pdf_struct_tree_node_t));
if (unlikely (ic->struct_root == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -2475,7 +2475,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 = calloc (1, sizeof(cairo_pdf_outline_entry_t));
outline_root = _cairo_calloc (1, sizeof(cairo_pdf_outline_entry_t));
if (unlikely (outline_root == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

View file

@ -1402,7 +1402,7 @@ _cairo_pdf_surface_create_smask_group (cairo_pdf_surface_t *surface,
{
cairo_pdf_smask_group_t *group;
group = calloc (1, sizeof (cairo_pdf_smask_group_t));
group = _cairo_calloc (1, sizeof (cairo_pdf_smask_group_t));
if (unlikely (group == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return NULL;

View file

@ -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 = calloc (1, sizeof (cairo_ps_form_t));
source_entry = _cairo_calloc (1, sizeof (cairo_ps_form_t));
if (source_entry == NULL) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail;

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 = calloc (1, sizeof (*pattern));
pattern = _cairo_calloc (1, sizeof (*pattern));
if (unlikely (pattern == NULL))
return _cairo_pattern_create_in_error (CAIRO_STATUS_NO_MEMORY);

View file

@ -1193,7 +1193,7 @@ _cairo_recording_surface_tag (void *abstract_surface,
surface->has_tags = TRUE;
command = calloc (1, sizeof (cairo_command_tag_t));
command = _cairo_calloc (1, sizeof (cairo_command_tag_t));
if (unlikely (command == NULL)) {
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@ -1516,7 +1516,7 @@ _cairo_recording_surface_copy__tag (cairo_recording_surface_t *surface,
cairo_command_tag_t *command;
cairo_status_t status;
command = calloc (1, sizeof (*command));
command = _cairo_calloc (1, sizeof (*command));
if (unlikely (command == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto err;

View file

@ -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 = calloc (subset->num_glyphs, sizeof (char *));
subset->glyph_names = _cairo_calloc (subset->num_glyphs, sizeof (char *));
if (unlikely (subset->glyph_names == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_HASH;

View file

@ -432,7 +432,7 @@ parse_attributes (const char *attributes, const attribute_spec_t *attrib_def, ca
goto fail1;
}
attrib = calloc (1, sizeof (attribute_t));
attrib = _cairo_calloc (1, sizeof (attribute_t));
if (unlikely (attrib == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto fail1;

View file

@ -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 = calloc (font->base.num_glyphs_in_face + 2, sizeof (subset_glyph_t));
font->glyphs = _cairo_calloc (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 = calloc (font->base.num_glyphs_in_face + 1, sizeof (int));
font->parent_to_subset = _cairo_calloc (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 = calloc (font->base.num_glyphs_in_face + 1, sizeof (int));
font->widths = _cairo_calloc (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,7 @@ 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 = calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
truetype_subset->widths = _cairo_calloc (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 = calloc (1, sizeof (cairo_type1_font_t));
font = _cairo_calloc (1, sizeof (cairo_type1_font_t));
if (unlikely (font == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->widths = calloc (scaled_font_subset->num_glyphs, sizeof (int));
font->widths = _cairo_calloc (scaled_font_subset->num_glyphs, sizeof (int));
if (unlikely (font->widths == NULL)) {
free (font);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -747,7 +747,7 @@ _cairo_type1_fallback_init_internal (cairo_type1_subset_t *type1_subset,
goto fail1;
}
type1_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (double));
type1_subset->widths = _cairo_calloc (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 +841,7 @@ _cairo_type2_charstrings_init (cairo_type2_charstrings_t *type2_subset,
_cairo_array_init (&type2_subset->charstrings, sizeof (cairo_array_t));
type2_subset->widths = calloc (font->scaled_font_subset->num_glyphs, sizeof (int));
type2_subset->widths = _cairo_calloc (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,7 @@ _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 = calloc (scaled_font_subset->num_glyphs, sizeof font->scaled_subset_index_to_glyphs[0]);
font->scaled_subset_index_to_glyphs = _cairo_calloc (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 +1355,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 = calloc (font->num_subrs, sizeof (font->subrs[0]));
font->subrs = _cairo_calloc (font->num_subrs, sizeof (font->subrs[0]));
if (unlikely (font->subrs == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -1410,7 +1410,7 @@ 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 = calloc (font->base.num_glyphs, sizeof font->type1_subset_index_to_glyphs[0]);
font->type1_subset_index_to_glyphs = _cairo_calloc (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 +1782,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset,
if (unlikely (type1_subset->base_font == NULL))
goto fail1;
type1_subset->widths = calloc (scaled_font_subset->num_glyphs, sizeof (double));
type1_subset->widths = _cairo_calloc (scaled_font_subset->num_glyphs, sizeof (double));
if (unlikely (type1_subset->widths == NULL))
goto fail2;

View file

@ -686,7 +686,7 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
connection->root = xcb_get_setup (xcb_connection);
connection->render = NULL;
connection->subpixel_orders = calloc (connection->root->roots_len, sizeof(*connection->subpixel_orders));
connection->subpixel_orders = _cairo_calloc (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

@ -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 = calloc (sizeof (DWORD), style->num_dashes);
dash_array = _cairo_calloc (sizeof (DWORD), style->num_dashes);
for (i = 0; i < style->num_dashes; i++) {
dash_array[i] = (DWORD) (scale * style->dash[i]);
}