Index: include/asterisk/strings.h =================================================================== --- include/asterisk/strings.h (revision 181248) +++ include/asterisk/strings.h (working copy) @@ -735,22 +735,42 @@ * } * \endcode */ +#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +AST_INLINE_API(int __attribute__((format(printf, 3, 0))) _ast_str_set_va(struct ast_str **buf, size_t max_len, const char *fmt, va_list ap, + const char *file, int lineno, const char *function), +{ + return __ast_debug_str_helper(buf, max_len, 0, fmt, ap, file, lineno, function); +} +) +#define ast_str_set_va(a,b,c,d) _ast_str_set_va(a,b,c,d,__FILE__,__LINE__,__PRETTY_FUNCTION__) +#else AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_set_va(struct ast_str **buf, size_t max_len, const char *fmt, va_list ap), { return __ast_str_helper(buf, max_len, 0, fmt, ap); } ) +#endif /*! * \brief Append to a dynamic string using a va_list * * Same as ast_str_set_va(), but append to the current content. */ +#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +AST_INLINE_API(int __attribute__((format(printf, 3, 0))) _ast_str_append_va(struct ast_str **buf, size_t max_len, const char *fmt, va_list ap, + const char *file, int lineno, const char *function), +{ + return __ast_debug_str_helper(buf, max_len, 1, fmt, ap, file, lineno, function); +} +) +#define ast_str_append_va(a,b,c,d) _ast_str_append_va(a,b,c,d,__FILE__,__LINE__,__PRETTY_FUNCTION__) +#else AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_append_va(struct ast_str **buf, size_t max_len, const char *fmt, va_list ap), { return __ast_str_helper(buf, max_len, 1, fmt, ap); } ) +#endif /*!\brief Set a dynamic string to a non-NULL terminated substring. */ AST_INLINE_API(char *ast_str_set_substr(struct ast_str **buf, size_t maxlen, const char *src, size_t maxsrc), @@ -797,7 +817,24 @@ * * All the rest is the same as ast_str_set_va() */ +#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) AST_INLINE_API( +int __attribute__((format(printf, 6, 7))) _ast_str_set( + struct ast_str **buf, size_t max_len, const char *file, int lineno, const char *function, const char *fmt, ...), +{ + int res; + va_list ap; + + va_start(ap, fmt); + res = _ast_str_set_va(buf, max_len, fmt, ap, file, lineno, function); + va_end(ap); + + return res; +} +) +#define ast_str_set(a,b,c,...) _ast_str_set(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__,c, ## __VA_ARGS__) +#else +AST_INLINE_API( int __attribute__((format(printf, 3, 4))) ast_str_set( struct ast_str **buf, size_t max_len, const char *fmt, ...), { @@ -811,6 +848,7 @@ return res; } ) +#endif /*! * \brief Append to a thread local dynamic string @@ -818,7 +856,24 @@ * The arguments, return values, and usage of this function are the same as * ast_str_set(), but the new data is appended to the current value. */ +#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) AST_INLINE_API( +int __attribute__((format(printf, 6, 7))) _ast_str_append( + struct ast_str **buf, size_t max_len, const char *file, int lineno, const char *function, const char *fmt, ...), +{ + int res; + va_list ap; + + va_start(ap, fmt); + res = _ast_str_append_va(buf, max_len, fmt, ap, file, lineno, function); + va_end(ap); + + return res; +} +) +#define ast_str_append(a,b,c,...) _ast_str_append(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__,c, ## __VA_ARGS__) +#else +AST_INLINE_API( int __attribute__((format(printf, 3, 4))) ast_str_append( struct ast_str **buf, size_t max_len, const char *fmt, ...), { @@ -832,6 +887,7 @@ return res; } ) +#endif /*! * \brief Compute a hash value on a string