|
|
@ -77,13 +77,14 @@ int __ast_str_helper(struct ast_str **buf, ssize_t max_len,
|
|
|
|
* reallocate the buffer and return a message telling to retry.
|
|
|
|
* reallocate the buffer and return a message telling to retry.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (need > (*buf)->__AST_STR_LEN && (max_len == 0 || (*buf)->__AST_STR_LEN < max_len) ) {
|
|
|
|
if (need > (*buf)->__AST_STR_LEN && (max_len == 0 || (*buf)->__AST_STR_LEN < max_len) ) {
|
|
|
|
|
|
|
|
int len = (int)(*buf)->__AST_STR_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 */
|
|
|
|
} else if (max_len == 0) { /* if unbounded, give more room for next time */
|
|
|
|
need += 16 + need / 4;
|
|
|
|
need += 16 + need / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (0) { /* debugging */
|
|
|
|
if (0) { /* debugging */
|
|
|
|
ast_verbose("extend from %d to %d\n", (int)(*buf)->__AST_STR_LEN, need);
|
|
|
|
ast_verbose("extend from %d to %d\n", len, need);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
|
|
|
#if (defined(MALLOC_DEBUG) && !defined(STANDALONE))
|
|
|
@ -92,7 +93,7 @@ int __ast_str_helper(struct ast_str **buf, ssize_t max_len,
|
|
|
|
ast_str_make_space(buf, need)
|
|
|
|
ast_str_make_space(buf, need)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
ast_verbose("failed to extend from %d to %d\n", (int)(*buf)->__AST_STR_LEN, need);
|
|
|
|
ast_verbose("failed to extend from %d to %d\n", len, need);
|
|
|
|
va_end(aq);
|
|
|
|
va_end(aq);
|
|
|
|
return AST_DYNSTR_BUILD_FAILED;
|
|
|
|
return AST_DYNSTR_BUILD_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|