diff -r d2b1e67b2b48 -r 75cb6590358b ucx/string.c --- a/ucx/string.c Fri Jul 12 20:50:18 2013 +0200 +++ b/ucx/string.c Sun Jul 14 17:11:34 2013 +0200 @@ -31,6 +31,7 @@ #include #include "string.h" +#include "allocator.h" sstr_t sstr(char *s) { sstr_t string; @@ -180,16 +181,30 @@ sstr_t sstrdup(sstr_t s) { sstr_t newstring; newstring.ptr = (char*) malloc(s.length + 1); - newstring.length = 0; if (newstring.ptr) { newstring.length = s.length; newstring.ptr[newstring.length] = 0; - + memcpy(newstring.ptr, s.ptr, s.length); } else { newstring.length = 0; } + + return newstring; +} +sstr_t sstrdup_alloc(UcxAllocator *allocator, sstr_t s) { + sstr_t newstring; + newstring.ptr = (char*)allocator->malloc(allocator->pool, s.length + 1); + if (newstring.ptr) { + newstring.length = s.length; + newstring.ptr[newstring.length] = 0; + + memcpy(newstring.ptr, s.ptr, s.length); + } else { + newstring.length = 0; + } + return newstring; }