dect
/
asterisk
Archived
13
0
Fork 0

When using ast_str with a non-ast_str-enabled API, we need to update the buffer

or otherwise, we cannot use ast_str_strlen().


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@168090 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
tilghman 2009-01-09 18:30:55 +00:00
parent f5972bb0a6
commit 205de4564c
2 changed files with 11 additions and 0 deletions

View File

@ -403,6 +403,16 @@ void ast_str_reset(struct ast_str *buf),
}
)
/*! \brief Update the length of the buffer, after using ast_str merely as a buffer.
* \param buf A pointer to the ast_str string.
*/
AST_INLINE_API(
void ast_str_update(struct ast_str *buf),
{
buf->__AST_STR_USED = strlen(buf->__AST_STR_STR);
}
)
/*! \brief Trims trailing whitespace characters from an ast_str string.
* \param buf A pointer to the ast_str string.
*/

View File

@ -1861,6 +1861,7 @@ static int handle_dbget(struct ast_channel *chan, AGI *agi, int argc, char **arg
do {
res = ast_db_get(argv[2], argv[3], ast_str_buffer(buf), ast_str_size(buf));
ast_str_update(buf);
if (ast_str_strlen(buf) < ast_str_size(buf) - 1) {
break;
}