diff options
author | Matthew Nicholson <mnicholson@digium.com> | 2010-06-22 12:58:28 +0000 |
---|---|---|
committer | Matthew Nicholson <mnicholson@digium.com> | 2010-06-22 12:58:28 +0000 |
commit | 9bbeb945e86e60ee64e7252c8d565a1840f9ff79 (patch) | |
tree | d1b3e83e55d557f8d2b4b2acab0ee5ca73e455fc /include/asterisk | |
parent | e3873889b8f3de5a01897c89817604e110e8c0f1 (diff) |
Merged revisions 271689 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r271689 | mnicholson | 2010-06-22 07:52:27 -0500 (Tue, 22 Jun 2010) | 8 lines
Modify chan_sip's packet generation api to automatically calculate the Content-Length. This is done by storing packet content in a buffer until it is actually time to send the packet, at which time the size of the packet is calculated. This change was made to ensure that the Content-Length is always correct.
(closes issue #17326)
Reported by: kenner
Tested by: mnicholson, kenner
Review: https://reviewboard.asterisk.org/r/693/
........
This change also adds an ast_str_copy_string() function (similar to ast_copy_string), that copies one ast_str into another, properly handling embedded nulls.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@271690 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r-- | include/asterisk/strings.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index f0940838d..49d3e0da8 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -582,6 +582,23 @@ int ast_str_make_space(struct ast_str **buf, size_t new_len), ) #endif +AST_INLINE_API( +int ast_str_copy_string(struct ast_str **dst, struct ast_str *src), +{ + + /* make sure our destination is large enough */ + if (src->__AST_STR_USED + 1 > (*dst)->__AST_STR_LEN) { + if (ast_str_make_space(dst, src->__AST_STR_USED + 1)) { + return -1; + } + } + + memcpy((*dst)->__AST_STR_STR, src->__AST_STR_STR, src->__AST_STR_USED + 1); + (*dst)->__AST_STR_USED = src->__AST_STR_USED; + return 0; +} +) + #define ast_str_alloca(init_len) \ ({ \ struct ast_str *__ast_str_buf; \ |