diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-04-12 22:30:45 -0700 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-10-19 21:40:25 +0200 |
commit | dde00b2f6848a38e9fdbe1e4c85373c8b12944b4 (patch) | |
tree | 070849ce4d0d19b3bb5c17ddf308023147357e7b /nx-X11/lib/X11/imRm.c | |
parent | 7d7224d8543e85e3a34a1cddf99f3eac9aa9050b (diff) | |
download | nx-libs-dde00b2f6848a38e9fdbe1e4c85373c8b12944b4.tar.gz nx-libs-dde00b2f6848a38e9fdbe1e4c85373c8b12944b4.tar.bz2 nx-libs-dde00b2f6848a38e9fdbe1e4c85373c8b12944b4.zip |
Convert malloc(strlen()); strcpy() sets to strdup
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib/X11/imRm.c')
-rw-r--r-- | nx-X11/lib/X11/imRm.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index 448cf41e6..3c28b1e29 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -793,19 +793,15 @@ _XimEncodeString( XPointer top, XPointer val) { - int len; char *string; char **out; if(val == (XPointer)NULL) { return False; } - len = strlen((char *)val); - if(!(string = (char *)Xmalloc(len + 1))) { + if (!(string = strdup((char *)val))) { return False; } - (void)strcpy(string, (char *)val); - string[len] = '\0'; out = (char **)((char *)top + info->offset); if(*out) { @@ -1163,21 +1159,18 @@ _XimDecodeString( XPointer top, XPointer val) { - int len = 0; char *in; char *string; in = *((char **)((char *)top + info->offset)); - if(in != (char *)NULL) { - len = strlen(in); + if (in != NULL) { + string = strdup(in); + } else { + string = Xcalloc(1, 1); /* strdup("") */ } - if(!(string = (char *)Xmalloc(len + 1))) { + if (string == NULL) { return False; } - if(in != (char *)NULL) { - (void)strcpy(string, in); - } - string[len] = '\0'; *((char **)val) = string; return True; } |