Make _cairo_calloc() consistent with _cairo_malloc()

ie

  _cairo_calloc(size)
  _cairo_calloc_ab(a, size)
This commit is contained in:
Adrian Johnson 2024-06-21 08:53:01 +09:30
parent 0700bb78a2
commit 8da24bf7fb
18 changed files with 87 additions and 56 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 = _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

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

@ -470,7 +470,7 @@ _cairo_ft_unscaled_font_init (cairo_ft_unscaled_font_t *unscaled,
unscaled->have_color = FT_HAS_COLOR (face) != 0;
unscaled->have_color_set = TRUE;
if (FT_Get_MM_Var (face, &ft_mm_var) == 0) {
unscaled->variations = _cairo_calloc (ft_mm_var->num_axis, sizeof (FT_Fixed));
unscaled->variations = _cairo_calloc_ab (ft_mm_var->num_axis, sizeof (FT_Fixed));
if (unscaled->variations)
FT_Get_Var_Design_Coordinates (face, ft_mm_var->num_axis, unscaled->variations);
FT_Done_MM_Var (face->glyph->library, ft_mm_var);
@ -1554,7 +1554,7 @@ _render_glyph_outline (FT_Face face,
if (bitmap_size < 0)
return _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
bitmap.buffer = _cairo_calloc (1, bitmap_size);
bitmap.buffer = _cairo_calloc (bitmap_size);
if (bitmap.buffer == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

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 = _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

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

@ -1583,7 +1583,7 @@ _cairo_pdf_interchange_write_document_dests (cairo_pdf_surface_t *surface)
return CAIRO_STATUS_SUCCESS;
}
ic->sorted_dests = _cairo_calloc (ic->num_dests, sizeof (cairo_pdf_named_dest_t *));
ic->sorted_dests = _cairo_calloc_ab (ic->num_dests, sizeof (cairo_pdf_named_dest_t *));
if (unlikely (ic->sorted_dests == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -1838,7 +1838,7 @@ _cairo_pdf_interchange_begin_dest_tag (cairo_pdf_surface_t *surface,
cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
if (surface->paginated_mode == CAIRO_PAGINATED_MODE_ANALYZE) {
dest = _cairo_calloc (1, sizeof (cairo_pdf_named_dest_t));
dest = _cairo_calloc (sizeof (cairo_pdf_named_dest_t));
if (unlikely (dest == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -2439,7 +2439,7 @@ _cairo_pdf_interchange_init (cairo_pdf_surface_t *surface)
_cairo_tag_stack_init (&ic->analysis_tag_stack);
_cairo_tag_stack_init (&ic->render_tag_stack);
ic->struct_root = _cairo_calloc (1, sizeof(cairo_pdf_struct_tree_node_t));
ic->struct_root = _cairo_calloc (sizeof(cairo_pdf_struct_tree_node_t));
if (unlikely (ic->struct_root == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -2483,7 +2483,7 @@ _cairo_pdf_interchange_init (cairo_pdf_surface_t *surface)
ic->mcid_order = 0;
_cairo_array_init (&ic->outline, sizeof(cairo_pdf_outline_entry_t *));
outline_root = _cairo_calloc (1, sizeof(cairo_pdf_outline_entry_t));
outline_root = _cairo_calloc (sizeof(cairo_pdf_outline_entry_t));
if (unlikely (outline_root == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);

View file

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

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 = _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

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

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

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 = _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

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

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

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