aboutsummaryrefslogtreecommitdiffstats
path: root/main/utils.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-11-29 17:37:31 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-11-29 17:37:31 +0000
commit700f9d585c82e839e2c9044a4ef1b89edeecb8e2 (patch)
tree7ff7922f2fcbefb50dede73f1b2ce95bebb16ac6 /main/utils.c
parent230fa9e9982b137c37ebf244700effc1bdbd65b1 (diff)
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 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48109 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/utils.c')
-rw-r--r--main/utils.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/main/utils.c b/main/utils.c
index 555800bce..d374e69bf 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -997,16 +997,8 @@ int ast_dynamic_str_thread_build_va(struct ast_dynamic_str **buf, size_t max_len
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);