File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 11## CHANGELOG
22
3+ ### v0.1.2 (2020-05-31)
4+
5+ * Memory copy changes to improve stability and performance.
6+
37### v0.1.1 (2020-04-23)
48
59* New string_buffer_is_released function.
Original file line number Diff line number Diff line change @@ -271,17 +271,19 @@ char *string_buffer_to_string(struct StringBuffer *buffer)
271271 return ("" );
272272 }
273273
274- size_t string_size = buffer -> content_size * sizeof (char );
275- char * string_copy = malloc (string_size );
274+ size_t content_size = buffer -> content_size ;
275+ size_t memory_size = content_size * sizeof (char );
276+ char * string_copy = malloc (memory_size );
276277 if (string_copy == NULL )
277278 {
278279 return (NULL );
279280 }
280281
281- buffer -> value [string_size ] = 0 ;
282+ buffer -> value [content_size ] = 0 ;
283+ string_copy [content_size ] = 0 ;
282284
283- string_copy = strcpy (string_copy , buffer -> value );
284- string_copy [string_size ] = 0 ;
285+ memcpy (string_copy , buffer -> value , memory_size );
286+ string_copy [content_size ] = 0 ;
285287
286288 return (string_copy );
287289}
You can’t perform that action at this time.
0 commit comments