summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-10-18 10:24:13 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-10-18 10:24:13 -0700
commitbbf3c582c97af3abfaf81e3ca63646d59fe6e28a (patch)
treed6a718fdf56757bb7ca8c01712c7e171583d398c /src
parent2e6bda49d062d5064efe66a066558f7d1eec7e78 (diff)
downloadxorg-lib-libXcursor-bbf3c582c97af3abfaf81e3ca63646d59fe6e28a.tar.gz
Use strdup() instead of malloc(strlen())+strcpy()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r--src/display.c16
-rw-r--r--src/file.c3
2 files changed, 4 insertions, 15 deletions
diff --git a/src/display.c b/src/display.c
index 7998fe7..77dd325 100644
--- a/src/display.c
+++ b/src/display.c
@@ -216,17 +216,8 @@ _XcursorGetDisplayInfo (Display *dpy)
v = XGetDefault (dpy, "Xcursor", "theme");
if (v)
{
- int len;
-
- len = strlen (v) + 1;
-
- info->theme = malloc (len);
- if (info->theme)
- strcpy (info->theme, v);
-
- info->theme_from_config = malloc (len);
- if (info->theme_from_config)
- strcpy (info->theme_from_config, v);
+ info->theme = strdup (v);
+ info->theme_from_config = strdup (v);
}
/*
@@ -342,10 +333,9 @@ XcursorSetTheme (Display *dpy, const char *theme)
if (theme)
{
- copy = malloc (strlen (theme) + 1);
+ copy = strdup (theme);
if (!copy)
return XcursorFalse;
- strcpy (copy, theme);
}
else
copy = NULL;
diff --git a/src/file.c b/src/file.c
index ce9de78..43163c2 100644
--- a/src/file.c
+++ b/src/file.c
@@ -86,12 +86,11 @@ XcursorImagesSetName (XcursorImages *images, const char *name)
if (!images || !name)
return;
- new = malloc (strlen (name) + 1);
+ new = strdup (name);
if (!new)
return;
- strcpy (new, name);
if (images->name)
free (images->name);
images->name = new;