From: Michael D. Lowis Date: Wed, 13 Aug 2014 03:13:28 +0000 (-0400) Subject: concat is a special case of insert X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f925c400d82588ad8764a480a3b1a3b72183e01d;p=projs%2Flibcds.git concat is a special case of insert --- diff --git a/source/string/str.c b/source/string/str.c index 576f68a..76ae599 100644 --- a/source/string/str.c +++ b/source/string/str.c @@ -67,15 +67,9 @@ str_t* str_set(str_t* p_str, size_t index, char val) str_t* str_concat(str_t* p_str1, str_t* p_str2) { - str_t* p_newstr = NULL; - size_t newsize; assert(NULL != p_str1); assert(NULL != p_str2); - newsize = sizeof(str_t) + p_str1->size + p_str2->size + 1; - p_newstr = (str_t*)mem_allocate(newsize, NULL); - memcpy(&(p_newstr->data[0]), p_str1->data, p_str1->size); - memcpy(&(p_newstr->data[p_str1->size]), p_str2->data, p_str2->size); - return p_newstr; + return str_insert(p_str1, p_str1->size, p_str2); } str_t* str_insert(str_t* p_str1, size_t index, str_t* p_str2)