Skip to content
Snippets Groups Projects
Commit 2703a1a9 authored by Luigi Rizzo's avatar Luigi Rizzo
Browse files

forgot this part...


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48520 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 97ce2f8f
No related branches found
No related tags found
No related merge requests found
...@@ -1003,20 +1003,16 @@ int __ast_str_helper(struct ast_str **buf, size_t max_len, ...@@ -1003,20 +1003,16 @@ int __ast_str_helper(struct ast_str **buf, size_t max_len,
if (need > (*buf)->len && (max_len == 0 || (*buf)->len < max_len) ) { if (need > (*buf)->len && (max_len == 0 || (*buf)->len < max_len) ) {
if (max_len && max_len < need) /* truncate as needed */ if (max_len && max_len < need) /* truncate as needed */
need = max_len; need = max_len;
else if (max_len == 0) /* if unbounded, give more room for next time */
/* We can only realloc malloc'ed space. */ need += 16 + need/4;
if ((*buf)->ts == DS_ALLOCA || (*buf)->ts == DS_STATIC) if (0) /* debugging */
return AST_DYNSTR_BUILD_FAILED; ast_verbose("extend from %d to %d\n", (int)(*buf)->len, need);
*buf = ast_realloc(*buf, need + sizeof(struct ast_str)); if (ast_str_make_space(buf, need)) {
if (*buf == NULL) /* XXX watch out, we leak memory here */ ast_verbose("failed to extend from %d to %d\n", (int)(*buf)->len, need);
return AST_DYNSTR_BUILD_FAILED; return AST_DYNSTR_BUILD_FAILED;
(*buf)->len = need; }
(*buf)->str[offset] = '\0'; /* Truncate the partial write. */ (*buf)->str[offset] = '\0'; /* Truncate the partial write. */
if ((*buf)->ts != DS_ALLOCA)
pthread_setspecific((*buf)->ts->key, *buf);
/* va_end() and va_start() must be done before calling /* va_end() and va_start() must be done before calling
* vsnprintf() again. */ * vsnprintf() again. */
return AST_DYNSTR_BUILD_RETRY; return AST_DYNSTR_BUILD_RETRY;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment