]> git.mdlowis.com Git - projs/libcds.git/commitdiff
Implemented str_set
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 12 Aug 2014 19:32:48 +0000 (15:32 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 12 Aug 2014 19:32:48 +0000 (15:32 -0400)
source/string/str.c

index eeed41578337e681b646cc4f595e3f00e775759e..5d58ac3d7a7451a752fac1cfa98124e5f7f612ec 100644 (file)
@@ -55,10 +55,14 @@ char str_at(str_t* p_str, size_t index)
 
 str_t* str_set(str_t* p_str, size_t index, char val)
 {
-    (void)p_str;
-    (void)index;
-    (void)val;
-    return NULL;
+    str_t* p_newstr = NULL;
+    assert(NULL != p_str);
+    if (index < p_str->size)
+    {
+        p_newstr = str_copy(p_str);
+        p_newstr->data[index] = val;
+    }
+    return p_newstr;
 }
 
 str_t* str_concat(str_t* p_str1, str_t* p_str2)