[PATCH v2 4/7] xkb: Use strdup for string copy

Pauli Nieminen ext-pauli.nieminen at nokia.com
Wed Jul 28 12:47:04 PDT 2010


Code is doing opencoded string copy that can be done with strdup library
call.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
---

new patch based on Peter's review that strdup should be used to
duplicating the string.

 xkb/XKBGAlloc.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index 7143e7a..f9d9482 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -668,17 +668,15 @@ register XkbPropertyPtr prop;
 	return NULL;
     }
     prop= &geom->properties[geom->num_properties];
-    prop->name= malloc(strlen(name)+1);
+    prop->name= strdup(name);
     if (!prop->name)
 	return NULL;
-    strcpy(prop->name,name);
-    prop->value= malloc(strlen(value)+1);
+    prop->value= strdup(value);
     if (!value) {
 	free(prop->name);
 	prop->name= NULL;
 	return NULL;
     }
-    strcpy(prop->value,value);
     geom->num_properties++;
     return prop;
 }
-- 
1.6.3.3



More information about the xorg-devel mailing list