diff options
author | Andrea Canciani <ranma42@gmail.com> | 2011-10-26 17:46:53 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2011-11-12 20:49:08 +0100 |
commit | c65d4e35dcdebc21d80c440944c11e1067743a8f (patch) | |
tree | e57740aaff7136d804e17e9737fa7dc4a393409e | |
parent | 6dfb12c7d7c4ada716c86dbb9af3446d9880ed36 (diff) | |
download | cairo-c65d4e35dcdebc21d80c440944c11e1067743a8f.tar.gz |
Use xstrdup instead of xmalloc when possible
Don't open code xstrdup, just use it.
-rw-r--r-- | perf/cairo-perf-report.c | 6 | ||||
-rw-r--r-- | test/cairo-test.c | 10 |
2 files changed, 4 insertions, 12 deletions
diff --git a/perf/cairo-perf-report.c b/perf/cairo-perf-report.c index 8df78c647..38bdc0cd4 100644 --- a/perf/cairo-perf-report.c +++ b/perf/cairo-perf-report.c @@ -388,11 +388,9 @@ cairo_perf_report_load (cairo_perf_report_t *report, if (name == NULL) name = "stdin"; - configuration = xmalloc (strlen (name) * sizeof (char) + 1); - strcpy (configuration, name); + configuration = xstrdup (name); baseName = basename (configuration); - report->configuration = xmalloc (strlen (baseName) * sizeof (char) + 1); - strcpy (report->configuration, baseName); + report->configuration = xstrdup (baseName); free (configuration); dot = strrchr (report->configuration, '.'); diff --git a/test/cairo-test.c b/test/cairo-test.c index a5ef6336a..7dda8c239 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -105,11 +105,9 @@ static int cairo_test_timeout = 60; static char * _cairo_test_fixup_name (const char *original) { - int len = strlen (original); char *name, *s; - name = xmalloc (len + 1); - s = memcpy (name, original, len + 1); + s = name = xstrdup (original); while ((s = strchr (s, '_')) != NULL) *s++ = '-'; @@ -505,7 +503,6 @@ cairo_test_get_reference_image (cairo_test_context_t *ctx, cairo_bool_t flatten) { cairo_surface_t *surface; - int len; if (ctx->ref_name != NULL) { if (strcmp (ctx->ref_name, filename) == 0) @@ -525,10 +522,7 @@ cairo_test_get_reference_image (cairo_test_context_t *ctx, if (cairo_surface_status (surface)) return surface; - len = strlen (filename); - ctx->ref_name = xmalloc (len + 1); - memcpy (ctx->ref_name, filename, len + 1); - + ctx->ref_name = xstrdup (filename); ctx->ref_image = surface; return _cairo_test_flatten_reference_image (ctx, flatten); } |