aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/strings.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asterisk/strings.h')
-rw-r--r--include/asterisk/strings.h17
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; \