summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2006-07-28 15:41:11 -0700
committerCarl Worth <cworth@cworth.org>2006-07-28 15:41:11 -0700
commit5e0f46cdebb5e086b344cc09b4537982a07e45cd (patch)
tree55656145d2de8d0271edc78094e178b77868accd
parent84b37568e1485c461df663f875ba5546b44e5c5c (diff)
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.
-rw-r--r--src/cairo-font.c8
-rw-r--r--src/cairo-pattern.c12
-rw-r--r--src/cairo-scaled-font.c6
-rw-r--r--src/cairo-surface.c12
-rw-r--r--src/cairo.c6
-rw-r--r--src/cairoint.h8
6 files changed, 27 insertions, 25 deletions
diff --git a/src/cairo-font.c b/src/cairo-font.c
index 5ef8b6c55..174d1c793 100644
--- a/src/cairo-font.c
+++ b/src/cairo-font.c
@@ -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,
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 1a62c6659..269a3e324 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -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);
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index a4fe953f5..d651e0103 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -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
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index fb25e075b..db47d1e6f 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -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,
diff --git a/src/cairo.c b/src/cairo.c
index 76f4831a4..b9d5b6d02 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -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);
diff --git a/src/cairoint.h b/src/cairoint.h
index 4eb0c3cb3..f690a9a13 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -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;
};