mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-18 09:40:44 +02:00
Standardize on unsigned for ref_count type and add CAIRO_REF_COUNT_INVALID
The CAIRO_REF_COUNT_INVALID macro simply hides the ((unsigned int)-1) cast to avoid warnings about comparison between signed and unsigned values.
This commit is contained in:
parent
84b37568e1
commit
5e0f46cdeb
6 changed files with 27 additions and 25 deletions
|
|
@ -49,7 +49,7 @@ static const cairo_font_face_backend_t _cairo_toy_font_face_backend;
|
|||
const cairo_font_face_t _cairo_font_face_nil = {
|
||||
{ 0 }, /* hash_entry */
|
||||
CAIRO_STATUS_NO_MEMORY, /* status */
|
||||
-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
{ 0, 0, 0, NULL }, /* user_data */
|
||||
&_cairo_toy_font_face_backend
|
||||
};
|
||||
|
|
@ -82,7 +82,7 @@ cairo_font_face_reference (cairo_font_face_t *font_face)
|
|||
if (font_face == NULL)
|
||||
return NULL;
|
||||
|
||||
if (font_face->ref_count == (unsigned int)-1)
|
||||
if (font_face->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return font_face;
|
||||
|
||||
/* We would normally assert (font_face->ref_count >0) here but we
|
||||
|
|
@ -108,7 +108,7 @@ cairo_font_face_destroy (cairo_font_face_t *font_face)
|
|||
if (font_face == NULL)
|
||||
return;
|
||||
|
||||
if (font_face->ref_count == (unsigned int)-1)
|
||||
if (font_face->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return;
|
||||
|
||||
assert (font_face->ref_count > 0);
|
||||
|
|
@ -202,7 +202,7 @@ cairo_font_face_set_user_data (cairo_font_face_t *font_face,
|
|||
void *user_data,
|
||||
cairo_destroy_func_t destroy)
|
||||
{
|
||||
if (font_face->ref_count == -1)
|
||||
if (font_face->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
|
||||
return _cairo_user_data_array_set_data (&font_face->user_data,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
const cairo_solid_pattern_t cairo_pattern_nil = {
|
||||
{ CAIRO_PATTERN_TYPE_SOLID, /* type */
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
CAIRO_STATUS_NO_MEMORY, /* status */
|
||||
{ 1., 0., 0., 1., 0., 0., }, /* matrix */
|
||||
CAIRO_FILTER_DEFAULT, /* filter */
|
||||
|
|
@ -40,7 +40,7 @@ const cairo_solid_pattern_t cairo_pattern_nil = {
|
|||
|
||||
static const cairo_solid_pattern_t cairo_pattern_nil_null_pointer = {
|
||||
{ CAIRO_PATTERN_TYPE_SOLID, /* type */
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
CAIRO_STATUS_NULL_POINTER,/* status */
|
||||
{ 1., 0., 0., 1., 0., 0., }, /* matrix */
|
||||
CAIRO_FILTER_DEFAULT, /* filter */
|
||||
|
|
@ -49,7 +49,7 @@ static const cairo_solid_pattern_t cairo_pattern_nil_null_pointer = {
|
|||
|
||||
static const cairo_solid_pattern_t cairo_pattern_nil_file_not_found = {
|
||||
{ CAIRO_PATTERN_TYPE_SOLID, /* type */
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
CAIRO_STATUS_FILE_NOT_FOUND, /* status */
|
||||
{ 1., 0., 0., 1., 0., 0., }, /* matrix */
|
||||
CAIRO_FILTER_DEFAULT, /* filter */
|
||||
|
|
@ -58,7 +58,7 @@ static const cairo_solid_pattern_t cairo_pattern_nil_file_not_found = {
|
|||
|
||||
static const cairo_solid_pattern_t cairo_pattern_nil_read_error = {
|
||||
{ CAIRO_PATTERN_TYPE_SOLID, /* type */
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
CAIRO_STATUS_READ_ERROR, /* status */
|
||||
{ 1., 0., 0., 1., 0., 0., }, /* matrix */
|
||||
CAIRO_FILTER_DEFAULT, /* filter */
|
||||
|
|
@ -514,7 +514,7 @@ cairo_pattern_reference (cairo_pattern_t *pattern)
|
|||
if (pattern == NULL)
|
||||
return NULL;
|
||||
|
||||
if (pattern->ref_count == (unsigned int)-1)
|
||||
if (pattern->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return pattern;
|
||||
|
||||
assert (pattern->ref_count > 0);
|
||||
|
|
@ -568,7 +568,7 @@ cairo_pattern_destroy (cairo_pattern_t *pattern)
|
|||
if (pattern == NULL)
|
||||
return;
|
||||
|
||||
if (pattern->ref_count == (unsigned int)-1)
|
||||
if (pattern->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return;
|
||||
|
||||
assert (pattern->ref_count > 0);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ _cairo_scaled_glyph_destroy (void *abstract_glyph)
|
|||
static const cairo_scaled_font_t _cairo_scaled_font_nil = {
|
||||
{ 0 }, /* hash_entry */
|
||||
CAIRO_STATUS_NO_MEMORY, /* status */
|
||||
-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
NULL, /* font_face */
|
||||
{ 1., 0., 0., 1., 0, 0}, /* font_matrix */
|
||||
{ 1., 0., 0., 1., 0, 0}, /* ctm */
|
||||
|
|
@ -510,7 +510,7 @@ cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font)
|
|||
if (scaled_font == NULL)
|
||||
return NULL;
|
||||
|
||||
if (scaled_font->ref_count == (unsigned int)-1)
|
||||
if (scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return scaled_font;
|
||||
|
||||
/* We would normally assert (scaled_font->ref_count > 0) here, but
|
||||
|
|
@ -565,7 +565,7 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font)
|
|||
if (scaled_font == NULL)
|
||||
return;
|
||||
|
||||
if (scaled_font->ref_count == (unsigned int)-1)
|
||||
if (scaled_font->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return;
|
||||
|
||||
/* cairo_scaled_font_t objects are cached and shared between
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ const cairo_surface_t _cairo_surface_nil = {
|
|||
&cairo_image_surface_backend, /* backend */
|
||||
CAIRO_SURFACE_TYPE_IMAGE,
|
||||
CAIRO_CONTENT_COLOR,
|
||||
-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
CAIRO_STATUS_NO_MEMORY, /* status */
|
||||
FALSE, /* finished */
|
||||
{ 0, /* size */
|
||||
|
|
@ -71,7 +71,7 @@ const cairo_surface_t _cairo_surface_nil_file_not_found = {
|
|||
&cairo_image_surface_backend, /* backend */
|
||||
CAIRO_SURFACE_TYPE_IMAGE,
|
||||
CAIRO_CONTENT_COLOR,
|
||||
-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
CAIRO_STATUS_FILE_NOT_FOUND, /* status */
|
||||
FALSE, /* finished */
|
||||
{ 0, /* size */
|
||||
|
|
@ -97,7 +97,7 @@ const cairo_surface_t _cairo_surface_nil_read_error = {
|
|||
&cairo_image_surface_backend, /* backend */
|
||||
CAIRO_SURFACE_TYPE_IMAGE,
|
||||
CAIRO_CONTENT_COLOR,
|
||||
-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
CAIRO_STATUS_READ_ERROR, /* status */
|
||||
FALSE, /* finished */
|
||||
{ 0, /* size */
|
||||
|
|
@ -362,7 +362,7 @@ cairo_surface_reference (cairo_surface_t *surface)
|
|||
if (surface == NULL)
|
||||
return NULL;
|
||||
|
||||
if (surface->ref_count == (unsigned int)-1)
|
||||
if (surface->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return surface;
|
||||
|
||||
assert (surface->ref_count > 0);
|
||||
|
|
@ -386,7 +386,7 @@ cairo_surface_destroy (cairo_surface_t *surface)
|
|||
if (surface == NULL)
|
||||
return;
|
||||
|
||||
if (surface->ref_count == (unsigned int)-1)
|
||||
if (surface->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return;
|
||||
|
||||
assert (surface->ref_count > 0);
|
||||
|
|
@ -495,7 +495,7 @@ cairo_surface_set_user_data (cairo_surface_t *surface,
|
|||
void *user_data,
|
||||
cairo_destroy_func_t destroy)
|
||||
{
|
||||
if (surface->ref_count == -1)
|
||||
if (surface->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
|
||||
return _cairo_user_data_array_set_data (&surface->user_data,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
#define CAIRO_TOLERANCE_MINIMUM 0.0002 /* We're limited by 16 bits of sub-pixel precision */
|
||||
|
||||
static const cairo_t cairo_nil = {
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_REF_COUNT_INVALID, /* ref_count */
|
||||
CAIRO_STATUS_NO_MEMORY, /* status */
|
||||
{ /* path */
|
||||
NULL, NULL, /* op_buf_head, op_buf_tail */
|
||||
|
|
@ -223,7 +223,7 @@ cairo_reference (cairo_t *cr)
|
|||
if (cr == NULL)
|
||||
return NULL;
|
||||
|
||||
if (cr->ref_count == (unsigned int)-1)
|
||||
if (cr->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return cr;
|
||||
|
||||
assert (cr->ref_count > 0);
|
||||
|
|
@ -247,7 +247,7 @@ cairo_destroy (cairo_t *cr)
|
|||
if (cr == NULL)
|
||||
return;
|
||||
|
||||
if (cr->ref_count == (unsigned int)-1)
|
||||
if (cr->ref_count == CAIRO_REF_COUNT_INVALID)
|
||||
return;
|
||||
|
||||
assert (cr->ref_count > 0);
|
||||
|
|
|
|||
|
|
@ -192,6 +192,8 @@ do { \
|
|||
assert (NOT_REACHED); \
|
||||
} while (0)
|
||||
|
||||
#define CAIRO_REF_COUNT_INVALID ((unsigned int) -1)
|
||||
|
||||
#include "cairo-wideint-private.h"
|
||||
|
||||
typedef int32_t cairo_fixed_16_16_t;
|
||||
|
|
@ -427,7 +429,7 @@ typedef struct _cairo_font_face_backend cairo_font_face_backend_t;
|
|||
*/
|
||||
typedef struct _cairo_unscaled_font {
|
||||
cairo_hash_entry_t hash_entry;
|
||||
int ref_count;
|
||||
unsigned int ref_count;
|
||||
const cairo_unscaled_font_backend_t *backend;
|
||||
} cairo_unscaled_font_t;
|
||||
|
||||
|
|
@ -457,7 +459,7 @@ struct _cairo_scaled_font {
|
|||
|
||||
/* useful bits for _cairo_scaled_font_nil */
|
||||
cairo_status_t status;
|
||||
int ref_count;
|
||||
unsigned int ref_count;
|
||||
|
||||
/* hash key members */
|
||||
cairo_font_face_t *font_face; /* may be NULL */
|
||||
|
|
@ -486,7 +488,7 @@ struct _cairo_font_face {
|
|||
/* hash_entry must be first */
|
||||
cairo_hash_entry_t hash_entry;
|
||||
cairo_status_t status;
|
||||
int ref_count;
|
||||
unsigned int ref_count;
|
||||
cairo_user_data_array_t user_data;
|
||||
const cairo_font_face_backend_t *backend;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue