[svn-commits] russell: trunk r48109 - /trunk/main/utils.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Nov 29 10:37:32 MST 2006


Author: russell
Date: Wed Nov 29 11:37:31 2006
New Revision: 48109

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48109
Log:
Go ahead and make this write unconditional.  Making it conditional is more work
in both the append and non-append modes.  Also, always truncating the partial
write makes the behavior of the function more consistent, where in any type of
write, no partial result is left in the buffer.

Thanks for the feedback, luigi

Modified:
    trunk/main/utils.c

Modified: trunk/main/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/main/utils.c?view=diff&rev=48109&r1=48108&r2=48109
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Wed Nov 29 11:37:31 2006
@@ -997,16 +997,8 @@
 			return AST_DYNSTR_BUILD_FAILED;
 		(*buf)->len = need;
 
-		/* Truncate the previous attempt.  This is only needed for the
-		 * append operation because if the write is from the beginning,
-		 * it will get automatically overwritten when this function
-		 * gets called again.  When appending, if this was not done,
-		 * this function would be called over and over again, because
-		 * each attempt would be appending more and more partial
-		 * strings, never having enough space to finish.
-		 */ 
-		if (append)
-			(*buf)->str[offset] = '\0';
+		/* Truncate the partial write. */
+		(*buf)->str[offset] = '\0';
 
 		if (ts)
 			pthread_setspecific(ts->key, *buf);



More information about the svn-commits mailing list