src/server/ucx/string.c

changeset 25
5dee29c7c530
parent 21
627b09ee74e4
child 28
f387669912e8
--- a/src/server/ucx/string.c	Thu Feb 23 13:10:04 2012 +0100
+++ b/src/server/ucx/string.c	Sat Feb 25 12:43:26 2012 +0100
@@ -85,7 +85,7 @@
 }
 
 int sstrcmp(sstr_t s1, sstr_t s2) {
-    return strncmp(s1.ptr, s2.ptr, s1.length>s2.length ? s2.length: s1.length);
+    return memcmp(s1.ptr, s2.ptr, s1.length>s2.length ? s2.length: s1.length);
 }
 
 sstr_t sstrdub(sstr_t s) {
@@ -95,7 +95,7 @@
     newstring.ptr[newstring.length] = 0;
 
     memcpy(newstring.ptr, s.ptr, s.length);
-
+    
     return newstring;
 }
 
@@ -125,17 +125,14 @@
     return newstr;
 }
 
-sstr_t sstrdub_mp(UcxMempool *mp, sstr_t s) {
+sstr_t sstrdup_mp(UcxMempool *mp, sstr_t s) {
     sstr_t newstring;
     newstring.ptr = ucx_mempool_malloc(mp, s.length + 1);
     newstring.length = s.length;
     newstring.ptr[newstring.length] = 0;
 
     /* TODO: sometimes memcpy and/or memmove destroy the source */
-    //memcpy(newstring.ptr, s.ptr, s.length);
-    for(int i=0;i<s.length;i++) {
-        newstring.ptr[i] = s.ptr[i];
-    }
+    memcpy(newstring.ptr, s.ptr, s.length);
 
     return newstring;
 }

mercurial