[cairo-commit] 2 commits - boilerplate/cairo-boilerplate.h boilerplate/cairo-boilerplate-pdf.c boilerplate/cairo-boilerplate-private.h perf/cairo-perf.h test/any2ppm.c test/bug-spline.c test/cairo-test.c test/cairo-test.h test/caps-tails-curve.c test/tiger.c
Bryce Harrington
bryce at kemper.freedesktop.org
Thu Nov 20 12:22:18 PST 2014
boilerplate/cairo-boilerplate-pdf.c | 2 --
boilerplate/cairo-boilerplate-private.h | 2 +-
boilerplate/cairo-boilerplate.h | 4 ++++
perf/cairo-perf.h | 4 ----
test/any2ppm.c | 2 +-
test/bug-spline.c | 3 +--
test/cairo-test.c | 4 ----
test/cairo-test.h | 4 ----
test/caps-tails-curve.c | 2 +-
test/tiger.c | 2 +-
10 files changed, 9 insertions(+), 20 deletions(-)
New commits:
commit 2c5af590ddbb08e0a46b7e37c5f0230b1805cd37
Author: Bryce Harrington <bryce at osg.samsung.com>
Date: Thu Nov 20 12:19:47 2014 -0800
Refactor ARRAY_LENGTH macro definitions in test code
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index d76d139..177cdf1 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -54,8 +54,6 @@ typedef struct _pdf_target_closure
cairo_surface_t *target;
} pdf_target_closure_t;
-#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
-
static cairo_surface_t *
_cairo_boilerplate_pdf_create_surface (const char *name,
cairo_content_t content,
diff --git a/boilerplate/cairo-boilerplate-private.h b/boilerplate/cairo-boilerplate-private.h
index a7a2dd0..d16a645 100644
--- a/boilerplate/cairo-boilerplate-private.h
+++ b/boilerplate/cairo-boilerplate-private.h
@@ -41,7 +41,7 @@ _cairo_boilerplate_register_backend (const cairo_boilerplate_target_t *targets,
void _register_##name__ (void); \
void _register_##name__ (void) { \
_cairo_boilerplate_register_backend (targets__, \
- sizeof (targets__) / sizeof (targets__[0])); \
+ ARRAY_LENGTH(targets__)); \
}
#define CAIRO_NO_BOILERPLATE(name__) \
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 4f6b8fd..515bb03 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -94,6 +94,10 @@
#define M_PI 3.14159265358979323846
#endif
+#ifndef ARRAY_LENGTH
+#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
+#endif
+
CAIRO_BEGIN_DECLS
/* A fake format we use for the flattened ARGB output of the PS and
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index b32b0e0..eb53d13 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -203,10 +203,6 @@ test_report_cmp_name (const void *a,
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
-#ifndef ARRAY_LENGTH
-#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
-#endif
-
CAIRO_PERF_DECL (fill);
CAIRO_PERF_DECL (paint);
CAIRO_PERF_DECL (paint_with_alpha);
diff --git a/test/any2ppm.c b/test/any2ppm.c
index 665314f..b60b4d9 100644
--- a/test/any2ppm.c
+++ b/test/any2ppm.c
@@ -100,7 +100,7 @@
#endif
#endif
-#define ARRAY_LENGTH(A) (sizeof (A) / sizeof (A[0]))
+#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
static int
_cairo_writen (int fd, char *buf, int len)
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 8dbf4c6..a351b01 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -83,10 +83,6 @@
#define TRUE !FALSE
#endif
-#ifndef ARRAY_LENGTH
-#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
-#endif
-
#if ! HAVE_ALARM || ! defined(SIGALRM)
#define alarm(X);
#endif
diff --git a/test/cairo-test.h b/test/cairo-test.h
index c753728..7e9605f 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -107,10 +107,6 @@ cairo_test_NaN (void)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
-#ifndef ARRAY_LENGTH
-#define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
-#endif
-
#define CAIRO_TEST_OUTPUT_DIR "output"
#define CAIRO_TEST_LOG_SUFFIX ".log"
commit 7edc5a8844b96862b866901568eb83fa56f4755b
Author: Bryce Harrington <bryce at osg.samsung.com>
Date: Fri Nov 14 18:10:16 2014 -0800
test: Use ARRAY_LENGTH macro
diff --git a/test/bug-spline.c b/test/bug-spline.c
index 00a915c..9a54a7c 100644
--- a/test/bug-spline.c
+++ b/test/bug-spline.c
@@ -56,7 +56,6 @@ static const struct spline {
{ 1, 0, 0, 1 },
}
};
-#define NUM_SPLINES (sizeof(splines)/sizeof(splines[0]))
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
@@ -68,7 +67,7 @@ draw (cairo_t *cr, int width, int height)
cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE);
- for (n = 0; n < NUM_SPLINES; n++) {
+ for (n = 0; n < ARRAY_LENGTH(splines); n++) {
cairo_set_line_width (cr, splines[n].line_width);
cairo_set_source_rgba (cr,
splines[n].rgba[0],
diff --git a/test/caps-tails-curve.c b/test/caps-tails-curve.c
index 25e5819..fa6aded 100644
--- a/test/caps-tails-curve.c
+++ b/test/caps-tails-curve.c
@@ -100,7 +100,7 @@ draw (cairo_t *cr, int width, int height)
cairo_set_line_width (cr, LINE_WIDTH);
- for (t = 0; t < sizeof(theta)/sizeof (theta[0]); t++) {
+ for (t = 0; t < ARRAY_LENGTH(theta); t++) {
cairo_save (cr);
cairo_translate (cr, 0, t * (SIZE + PAD) + PAD);
draw_caps_joins (cr, theta[t]);
diff --git a/test/tiger.c b/test/tiger.c
index 6f45f1f..059bb84 100644
--- a/test/tiger.c
+++ b/test/tiger.c
@@ -37,7 +37,7 @@ draw (cairo_t *cr, int width, int height)
cairo_translate (cr, width/2, height/2);
cairo_scale (cr, .85, .85);
- for (i = 0; i < sizeof (tiger_commands)/sizeof(tiger_commands[0]);i++) {
+ for (i = 0; i < ARRAY_LENGTH(tiger_commands); i++) {
const struct command *cmd = &tiger_commands[i];
switch (cmd->type) {
case 'm':
More information about the cairo-commit
mailing list