From a41e1275d28317c88e29b7f142cfc835673c01f5 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 12 Jun 2009 12:32:51 +0100 Subject: [PATCH] [boilerplate] Make array of targets const. Protect the boilerplate targets from unexpected modifications. --- boilerplate/cairo-boilerplate.c | 8 ++++---- boilerplate/cairo-boilerplate.h | 4 ++-- perf/cairo-perf-trace.c | 6 +++--- perf/cairo-perf.c | 4 ++-- perf/cairo-perf.h | 4 ++-- test/cairo-test.h | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c index 031733799..e3d96a266 100644 --- a/boilerplate/cairo-boilerplate.c +++ b/boilerplate/cairo-boilerplate.c @@ -270,7 +270,7 @@ cairo_boilerplate_get_image_surface_from_png (const char *filename, return surface; } -static cairo_boilerplate_target_t targets[] = +static const cairo_boilerplate_target_t targets[] = { /* I'm uncompromising about leaving the image backend as 0 * for tolerance. There shouldn't ever be anything that is out of @@ -744,13 +744,13 @@ static cairo_boilerplate_target_t targets[] = #endif }; -cairo_boilerplate_target_t ** +const cairo_boilerplate_target_t ** cairo_boilerplate_get_targets (int *pnum_targets, cairo_bool_t *plimited_targets) { size_t i, num_targets; cairo_bool_t limited_targets = FALSE; const char *tname; - cairo_boilerplate_target_t **targets_to_test; + const cairo_boilerplate_target_t **targets_to_test; if ((tname = getenv ("CAIRO_TEST_TARGET")) != NULL && *tname) { /* check the list of targets specified by the user */ @@ -868,7 +868,7 @@ cairo_boilerplate_get_image_target (cairo_content_t content) } void -cairo_boilerplate_free_targets (cairo_boilerplate_target_t **targets) +cairo_boilerplate_free_targets (const cairo_boilerplate_target_t **targets) { free (targets); } diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h index ba3c4eb5a..a2763bbf3 100644 --- a/boilerplate/cairo-boilerplate.h +++ b/boilerplate/cairo-boilerplate.h @@ -168,11 +168,11 @@ typedef struct _cairo_boilerplate_target const cairo_boilerplate_target_t * cairo_boilerplate_get_image_target (cairo_content_t content); -cairo_boilerplate_target_t ** +const cairo_boilerplate_target_t ** cairo_boilerplate_get_targets (int *num_targets, cairo_bool_t *limited_targets); void -cairo_boilerplate_free_targets (cairo_boilerplate_target_t **targets); +cairo_boilerplate_free_targets (const cairo_boilerplate_target_t **targets); cairo_surface_t * _cairo_boilerplate_get_image_surface (cairo_surface_t *src, diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c index 2a468632b..6ef44a944 100644 --- a/perf/cairo-perf-trace.c +++ b/perf/cairo-perf-trace.c @@ -66,7 +66,7 @@ * loops wouldn't count the real work, just the recording by the * meta-surface. */ static cairo_bool_t -target_is_measurable (cairo_boilerplate_target_t *target) +target_is_measurable (const cairo_boilerplate_target_t *target) { if (target->content != CAIRO_CONTENT_COLOR_ALPHA) return FALSE; @@ -571,7 +571,7 @@ have_trace_filenames (cairo_perf_t *perf) static void cairo_perf_trace (cairo_perf_t *perf, - cairo_boilerplate_target_t *target, + const cairo_boilerplate_target_t *target, const char *trace) { cairo_surface_t *surface; @@ -648,7 +648,7 @@ main (int argc, char *argv[]) names_are_traces = have_trace_filenames (&perf); for (i = 0; i < perf.num_targets; i++) { - cairo_boilerplate_target_t *target = perf.targets[i]; + const cairo_boilerplate_target_t *target = perf.targets[i]; if (! perf.list_only && ! target_is_measurable (target)) continue; diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c index 8fb71b15f..be4368133 100644 --- a/perf/cairo-perf.c +++ b/perf/cairo-perf.c @@ -64,7 +64,7 @@ const cairo_perf_case_t perf_cases[]; * loops wouldn't count the real work, just the recording by the * meta-surface. */ static cairo_bool_t -target_is_measurable (cairo_boilerplate_target_t *target) +target_is_measurable (const cairo_boilerplate_target_t *target) { switch (target->expected_type) { case CAIRO_SURFACE_TYPE_IMAGE: @@ -417,7 +417,7 @@ main (int argc, char *argv[]) perf.times = xmalloc (perf.iterations * sizeof (cairo_perf_ticks_t)); for (i = 0; i < perf.num_targets; i++) { - cairo_boilerplate_target_t *target = perf.targets[i]; + const cairo_boilerplate_target_t *target = perf.targets[i]; if (! target_is_measurable (target)) continue; diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h index fbb1500b9..8ea9149f3 100644 --- a/perf/cairo-perf.h +++ b/perf/cairo-perf.h @@ -84,9 +84,9 @@ typedef struct _cairo_perf { /* Stuff used internally */ cairo_perf_ticks_t *times; - cairo_boilerplate_target_t **targets; + const cairo_boilerplate_target_t **targets; int num_targets; - cairo_boilerplate_target_t *target; + const cairo_boilerplate_target_t *target; unsigned int test_number; unsigned int size; cairo_t *cr; diff --git a/test/cairo-test.h b/test/cairo-test.h index 5a5be44ea..afdc88891 100644 --- a/test/cairo-test.h +++ b/test/cairo-test.h @@ -187,7 +187,7 @@ struct _cairo_test_context { size_t num_targets; cairo_bool_t limited_targets; - cairo_boilerplate_target_t **targets_to_test; + const cairo_boilerplate_target_t **targets_to_test; cairo_bool_t own_targets; int malloc_failure;