mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-02-19 00:40:36 +01:00
Use xstrdup instead of xmalloc when possible
Don't open code xstrdup, just use it.
This commit is contained in:
parent
6dfb12c7d7
commit
c65d4e35dc
2 changed files with 4 additions and 12 deletions
|
|
@ -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, '.');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue