From 6121f4fccfe8d98fb09c096402da05d29d10b9e8 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 19 Apr 2007 16:21:39 -0700 Subject: cairo-perf-diff-files: Simplify code to grow report->tests --- perf/cairo-perf-diff-files.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'perf') diff --git a/perf/cairo-perf-diff-files.c b/perf/cairo-perf-diff-files.c index 7b64504f2..9492c2064 100644 --- a/perf/cairo-perf-diff-files.c +++ b/perf/cairo-perf-diff-files.c @@ -369,8 +369,8 @@ cairo_perf_report_load (cairo_perf_report_t *report, const char *filename) size_t line_size = 0; report->name = filename; - report->tests = NULL; - report->tests_size = 0; + report->tests_size = 16; + report->tests = xmalloc (report->tests_size * sizeof (test_report_t)); report->tests_count = 0; file = fopen (filename, "r"); @@ -382,13 +382,9 @@ cairo_perf_report_load (cairo_perf_report_t *report, const char *filename) while (1) { if (report->tests_count == report->tests_size) { - report->tests_size = report->tests_size ? 2 * report->tests_size : 16; - report->tests = realloc (report->tests, - report->tests_size * sizeof (test_report_t)); - if (report->tests == NULL) { - fprintf (stderr, "Out of memory.\n"); - exit (1); - } + report->tests_size *= 2; + report->tests = xrealloc (report->tests, + report->tests_size * sizeof (test_report_t)); } line_number++; -- cgit v1.2.3