summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build_tools/cflags.xml2
-rw-r--r--channels/chan_sip.c7
-rwxr-xr-xconfigure203
-rw-r--r--configure.ac6
-rw-r--r--funcs/func_channel.c22
-rw-r--r--include/asterisk.h3
-rw-r--r--include/asterisk/astmm.h202
-rw-r--r--include/asterisk/rtp_engine.h2
-rw-r--r--include/asterisk/utils.h358
-rw-r--r--main/astmm.c218
-rw-r--r--res/res_pjsip_sdp_rtp.c4
-rw-r--r--third-party/pjproject/patches/asterisk_malloc_debug.h50
-rw-r--r--utils/.gitignore1
-rw-r--r--utils/Makefile17
-rw-r--r--utils/ael_main.c1
-rw-r--r--utils/astman.c1
-rw-r--r--utils/check_expr.c1
-rw-r--r--utils/conf2ael.c1
-rw-r--r--utils/extconf.c221
19 files changed, 431 insertions, 889 deletions
diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml
index f05f42869..c4f9458ec 100644
--- a/build_tools/cflags.xml
+++ b/build_tools/cflags.xml
@@ -78,11 +78,9 @@
<support_level>extended</support_level>
</member>
<member name="MALLOC_DEBUG" displayname="Keep Track of Memory Allocations">
- <conflict>DEBUG_CHAOS</conflict>
<support_level>core</support_level>
</member>
<member name="DEBUG_CHAOS" displayname="Randomly FAIL memory allocations or other operations">
- <conflict>MALLOC_DEBUG</conflict>
<support_level>core</support_level>
</member>
<member name="ADDRESS_SANITIZER" displayname="Address Sanitizer">
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 5030af453..138021e82 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -34451,10 +34451,9 @@ static int peer_ipcmp_cb_full(void *obj, void *arg, void *data, int flags)
}
/* We matched the IP, check to see if we need to match by port as well. */
- if ((peer->transports & peer2->transports) & (AST_TRANSPORT_TLS | AST_TRANSPORT_TCP)) {
- /* peer matching on port is not possible with TCP/TLS */
- return CMP_MATCH | CMP_STOP;
- } else if (ast_test_flag(&peer2->flags[0], SIP_INSECURE_PORT)) {
+ if (((peer->transports & peer2->transports) &
+ (AST_TRANSPORT_UDP | AST_TRANSPORT_WS | AST_TRANSPORT_WSS)) &&
+ ast_test_flag(&peer2->flags[0], SIP_INSECURE_PORT)) {
/* We are allowing match without port for peers configured that
* way in this pass through the peers. */
return ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT) ?
diff --git a/configure b/configure
index 4e07f0e1b..9245063da 100755
--- a/configure
+++ b/configure
@@ -6820,10 +6820,8 @@ $as_echo "no" >&6; }
fi
-for ac_prog in python2 python2.7
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+# Extract the first word of "python", so it can be a program name with args.
+set dummy python; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PYTHON+:} false; then :
@@ -6849,6 +6847,7 @@ done
done
IFS=$as_save_IFS
+ test -z "$ac_cv_path_PYTHON" && ac_cv_path_PYTHON=":"
;;
esac
fi
@@ -6862,10 +6861,6 @@ $as_echo "no" >&6; }
fi
- test -n "$PYTHON" && break
-done
-test -n "$PYTHON" || PYTHON=":"
-
# Extract the first word of "find", so it can be a program name with args.
set dummy find; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -26098,188 +26093,12 @@ if test -n "$PYTHONDEV_CFLAGS"; then
pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python >= 3\""; } >&5
- ($PKG_CONFIG --exists --print-errors "python >= 3") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python >= 3" 2>/dev/null`
- test "x$?" != "x0" && pkg_failed=yes
-else
- pkg_failed=yes
-fi
- else
- pkg_failed=untried
-fi
-if test -n "$PYTHONDEV_LIBS"; then
- pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
- elif test -n "$PKG_CONFIG"; then
- if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python >= 3\""; } >&5
- ($PKG_CONFIG --exists --print-errors "python >= 3") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python >= 3" 2>/dev/null`
- test "x$?" != "x0" && pkg_failed=yes
-else
- pkg_failed=yes
-fi
- else
- pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
- _pkg_short_errors_supported=yes
-else
- _pkg_short_errors_supported=no
-fi
- if test $_pkg_short_errors_supported = yes; then
- PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python >= 3" 2>&1`
- else
- PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python >= 3" 2>&1`
- fi
- # Put the nasty error message in config.log where it belongs
- echo "$PYTHONDEV_PKG_ERRORS" >&5
-
-
- PBX_PYTHONDEV=0
-
-
-elif test $pkg_failed = untried; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
- PBX_PYTHONDEV=0
-
-
-else
- PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS
- PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
- PBX_PYTHONDEV=1
- PYTHONDEV_INCLUDE="$PYTHONDEV_CFLAGS"
- PYTHONDEV_LIB="$PYTHONDEV_LIBS"
-
-$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
-
-
-fi
- fi
-
-
- if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5
-$as_echo_n "checking for PYTHONDEV... " >&6; }
-
-if test -n "$PYTHONDEV_CFLAGS"; then
- pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
- if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python3\""; } >&5
- ($PKG_CONFIG --exists --print-errors "python3") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python3" 2>/dev/null`
- test "x$?" != "x0" && pkg_failed=yes
-else
- pkg_failed=yes
-fi
- else
- pkg_failed=untried
-fi
-if test -n "$PYTHONDEV_LIBS"; then
- pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
- elif test -n "$PKG_CONFIG"; then
- if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python3\""; } >&5
- ($PKG_CONFIG --exists --print-errors "python3") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python3" 2>/dev/null`
- test "x$?" != "x0" && pkg_failed=yes
-else
- pkg_failed=yes
-fi
- else
- pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
- _pkg_short_errors_supported=yes
-else
- _pkg_short_errors_supported=no
-fi
- if test $_pkg_short_errors_supported = yes; then
- PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python3" 2>&1`
- else
- PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python3" 2>&1`
- fi
- # Put the nasty error message in config.log where it belongs
- echo "$PYTHONDEV_PKG_ERRORS" >&5
-
-
- PBX_PYTHONDEV=0
-
-
-elif test $pkg_failed = untried; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
- PBX_PYTHONDEV=0
-
-
-else
- PYTHONDEV_CFLAGS=$pkg_cv_PYTHONDEV_CFLAGS
- PYTHONDEV_LIBS=$pkg_cv_PYTHONDEV_LIBS
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
- PBX_PYTHONDEV=1
- PYTHONDEV_INCLUDE="$PYTHONDEV_CFLAGS"
- PYTHONDEV_LIB="$PYTHONDEV_LIBS"
-
-$as_echo "#define HAVE_PYTHONDEV 1" >>confdefs.h
-
-
-fi
- fi
-
-
- if test "x${PBX_PYTHONDEV}" != "x1" -a "${USE_PYTHONDEV}" != "no"; then
-
-pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PYTHONDEV" >&5
-$as_echo_n "checking for PYTHONDEV... " >&6; }
-
-if test -n "$PYTHONDEV_CFLAGS"; then
- pkg_cv_PYTHONDEV_CFLAGS="$PYTHONDEV_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
- if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python-3.6\""; } >&5
- ($PKG_CONFIG --exists --print-errors "python-3.6") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "python") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python-3.6" 2>/dev/null`
+ pkg_cv_PYTHONDEV_CFLAGS=`$PKG_CONFIG --cflags "python" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -26291,12 +26110,12 @@ if test -n "$PYTHONDEV_LIBS"; then
pkg_cv_PYTHONDEV_LIBS="$PYTHONDEV_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python-3.6\""; } >&5
- ($PKG_CONFIG --exists --print-errors "python-3.6") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"python\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "python") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python-3.6" 2>/dev/null`
+ pkg_cv_PYTHONDEV_LIBS=`$PKG_CONFIG --libs "python" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -26317,9 +26136,9 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python-3.6" 2>&1`
+ PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "python" 2>&1`
else
- PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python-3.6" 2>&1`
+ PYTHONDEV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "python" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$PYTHONDEV_PKG_ERRORS" >&5
diff --git a/configure.ac b/configure.ac
index de34c4206..219f85d0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -261,7 +261,7 @@ AC_PATH_PROG([CAT], [cat], :)
AC_PATH_PROG([CUT], [cut], :)
AC_PATH_PROG([FLEX], [flex], :)
AC_PATH_PROG([GREP], [grep], :)
-AC_PATH_PROGS([PYTHON], [python2 python2.7], :)
+AC_PATH_PROG([PYTHON], [python], :)
AC_PATH_PROG([FIND], [find], :)
AC_PATH_PROG([COMPRESS], [compress], :)
AC_PATH_PROG([BASENAME], [basename], :)
@@ -2310,9 +2310,7 @@ fi
AC_SUBST([PYTHONDEV_LIB])
AC_SUBST([PYTHONDEV_INCLUDE])
-AST_PKG_CONFIG_CHECK([PYTHONDEV], [python >= 3])
-AST_PKG_CONFIG_CHECK([PYTHONDEV], [python3])
-AST_PKG_CONFIG_CHECK([PYTHONDEV], [python-3.6])
+AST_PKG_CONFIG_CHECK([PYTHONDEV], [python])
AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index e290fa09a..f82dad37a 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -205,10 +205,6 @@
<enum name="videonativeformat">
<para>R/O format used natively for video</para>
</enum>
- <enum name="trace">
- <para>R/W whether or not context tracing is enabled, only available
- <emphasis>if CHANNEL_TRACE is defined</emphasis>.</para>
- </enum>
<enum name="hangupsource">
<para>R/W returns the channel responsible for hangup.</para>
</enum>
@@ -328,10 +324,6 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
locked_copy_string(chan, buf, ast_format_get_name(ast_channel_readformat(chan)), len);
} else if (!strcasecmp(data, "audiowriteformat")) {
locked_copy_string(chan, buf, ast_format_get_name(ast_channel_writeformat(chan)), len);
-#ifdef CHANNEL_TRACE
- } else if (!strcasecmp(data, "trace")) {
- locked_copy_string(chan, buf, ast_channel_trace_is_enabled(chan) ? "1" : "0", len);
-#endif
} else if (!strcasecmp(data, "tonezone") && ast_channel_zone(chan)) {
locked_copy_string(chan, buf, ast_channel_zone(chan)->country, len);
} else if (!strcasecmp(data, "dtmf_features")) {
@@ -515,20 +507,6 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
else if (!strcasecmp(data, "hangupsource"))
/* XXX - should we be forcing this here? */
ast_set_hangupsource(chan, value, 0);
-#ifdef CHANNEL_TRACE
- else if (!strcasecmp(data, "trace")) {
- ast_channel_lock(chan);
- if (ast_true(value))
- ret = ast_channel_trace_enable(chan);
- else if (ast_false(value))
- ret = ast_channel_trace_disable(chan);
- else {
- ret = -1;
- ast_log(LOG_WARNING, "Invalid value for CHANNEL(trace).\n");
- }
- ast_channel_unlock(chan);
- }
-#endif
else if (!strcasecmp(data, "tonezone")) {
struct ast_tone_zone *new_zone;
if (!(new_zone = ast_get_indication_zone(value))) {
diff --git a/include/asterisk.h b/include/asterisk.h
index 27d66b776..c1ed6af3f 100644
--- a/include/asterisk.h
+++ b/include/asterisk.h
@@ -20,10 +20,7 @@
#include "asterisk/autoconfig.h"
#include "asterisk/compat.h"
-
-#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2)
#include "asterisk/astmm.h"
-#endif
/* Default to allowing the umask or filesystem ACLs to determine actual file
* creation permissions
diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h
index 4e4a65b31..13ebe030c 100644
--- a/include/asterisk/astmm.h
+++ b/include/asterisk/astmm.h
@@ -17,13 +17,12 @@
*/
/*! \file
- * \brief Asterisk memory usage debugging
- * This file provides headers for MALLOC_DEBUG, a define used for tracking down
- * memory leaks. It should never be \#included directly; always use the
- * MALLOC_DEBUG definition in menuselect to activate those functions.
+ * \brief Asterisk memory management routines
+ *
+ * This file should never be \#included directly, it is included
+ * by asterisk.h.
*/
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -32,26 +31,45 @@ extern "C" {
#define _ASTERISK_ASTMM_H
/* IWYU pragma: private, include "asterisk.h" */
-#if defined(MALLOC_DEBUG)
+#if defined(MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2)
#define __AST_DEBUG_MALLOC
void __ast_mm_init_phase_1(void);
void __ast_mm_init_phase_2(void);
#endif
-void *ast_std_malloc(size_t size);
-void *ast_std_calloc(size_t nmemb, size_t size);
+void *ast_std_malloc(size_t size) attribute_malloc;
+void *ast_std_calloc(size_t nmemb, size_t size) attribute_malloc;
void *ast_std_realloc(void *ptr, size_t size);
void ast_std_free(void *ptr);
+
+/*!
+ * \brief free() wrapper
+ *
+ * ast_free_ptr should be used when a function pointer for free() needs to be passed
+ * as the argument to a function. Otherwise, astmm will cause seg faults.
+ */
void ast_free_ptr(void *ptr);
-void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
-void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
-void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func);
+void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc;
+void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc;
+void *__ast_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc;
void __ast_free(void *ptr, const char *file, int lineno, const char *func);
+void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
+char *__ast_strdup(const char *s, const char *file, int lineno, const char *func) attribute_malloc;
+char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc;
+int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
+ __attribute__((format(printf, 5, 6)));
+int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
+ __attribute__((format(printf, 2, 0)));
+
+/* The __ast_repl functions should not used from Asterisk sources, they are exposed
+ * for use by ASTMM_REDIRECT and bundled pjproject. */
+void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc;
+void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc;
void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
-char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func);
-char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
+char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func) attribute_malloc;
+char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc;
int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
__attribute__((format(printf, 5, 6)));
int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
@@ -123,22 +141,22 @@ int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char
#if ASTMM_LIBC == ASTMM_REDIRECT
/* Redefine libc functions to our own versions */
-#define calloc(a, b) \
- __ast_repl_calloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define malloc(a) \
- __ast_repl_malloc(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define free(a) \
- __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define realloc(a, b) \
- __ast_repl_realloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define strdup(a) \
- __ast_repl_strdup(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define strndup(a, b) \
- __ast_repl_strndup(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define asprintf(a, b, c...) \
- __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
-#define vasprintf(a, b, c) \
- __ast_repl_vasprintf(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define calloc(nmemb, size) \
+ __ast_repl_calloc(nmemb, size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define malloc(size) \
+ __ast_repl_malloc(size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define free(ptr) \
+ __ast_free(ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define realloc(ptr, size) \
+ __ast_repl_realloc(ptr, size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define strdup(s) \
+ __ast_repl_strdup(s, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define strndup(s, n) \
+ __ast_repl_strndup(s, n, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define asprintf(strp, format, args...) \
+ __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, strp, format, args)
+#define vasprintf(strp, format, ap) \
+ __ast_repl_vasprintf(strp, format, ap, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#elif ASTMM_LIBC == ASTMM_BLOCK
@@ -171,6 +189,132 @@ int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char
#define ast_free(a) \
__ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+/*!
+ * \brief A wrapper for malloc()
+ *
+ * ast_malloc() is a wrapper for malloc() that will generate an Asterisk log
+ * message in the case that the allocation fails.
+ *
+ * The argument and return value are the same as malloc()
+ */
+#define ast_malloc(len) \
+ __ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+/*!
+ * \brief A wrapper for calloc()
+ *
+ * ast_calloc() is a wrapper for calloc() that will generate an Asterisk log
+ * message in the case that the allocation fails.
+ *
+ * The arguments and return value are the same as calloc()
+ */
+#define ast_calloc(num, len) \
+ __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+/*!
+ * \brief A wrapper for calloc() for use in cache pools
+ *
+ * ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log
+ * message in the case that the allocation fails. When memory debugging is in use,
+ * the memory allocated by this function will be marked as 'cache' so it can be
+ * distinguished from normal memory allocations.
+ *
+ * The arguments and return value are the same as calloc()
+ */
+#define ast_calloc_cache(num, len) \
+ __ast_calloc_cache((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+/*!
+ * \brief A wrapper for realloc()
+ *
+ * ast_realloc() is a wrapper for realloc() that will generate an Asterisk log
+ * message in the case that the allocation fails.
+ *
+ * The arguments and return value are the same as realloc()
+ */
+#define ast_realloc(p, len) \
+ __ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+/*!
+ * \brief A wrapper for strdup()
+ *
+ * ast_strdup() is a wrapper for strdup() that will generate an Asterisk log
+ * message in the case that the allocation fails.
+ *
+ * ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL
+ * argument is provided, ast_strdup will return NULL without generating any
+ * kind of error log message.
+ *
+ * The argument and return value are the same as strdup()
+ */
+#define ast_strdup(str) \
+ __ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+/*!
+ * \brief A wrapper for strndup()
+ *
+ * ast_strndup() is a wrapper for strndup() that will generate an Asterisk log
+ * message in the case that the allocation fails.
+ *
+ * ast_strndup(), unlike strndup(), can safely accept a NULL argument for the
+ * string to duplicate. If a NULL argument is provided, ast_strdup will return
+ * NULL without generating any kind of error log message.
+ *
+ * The arguments and return value are the same as strndup()
+ */
+#define ast_strndup(str, len) \
+ __ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+/*!
+ * \brief A wrapper for asprintf()
+ *
+ * ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log
+ * message in the case that the allocation fails.
+ *
+ * The arguments and return value are the same as asprintf()
+ */
+#define ast_asprintf(ret, fmt, ...) \
+ __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__)
+
+/*!
+ * \brief A wrapper for vasprintf()
+ *
+ * ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log
+ * message in the case that the allocation fails.
+ *
+ * The arguments and return value are the same as vasprintf()
+ */
+#define ast_vasprintf(ret, fmt, ap) \
+ __ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+/*!
+ \brief call __builtin_alloca to ensure we get gcc builtin semantics
+ \param size The size of the buffer we want allocated
+
+ This macro will attempt to allocate memory from the stack. If it fails
+ you won't get a NULL returned, but a SEGFAULT if you're lucky.
+*/
+#define ast_alloca(size) __builtin_alloca(size)
+
+#if !defined(ast_strdupa) && defined(__GNUC__)
+/*!
+ * \brief duplicate a string in memory from the stack
+ * \param s The string to duplicate
+ *
+ * This macro will duplicate the given string. It returns a pointer to the stack
+ * allocatted memory for the new string.
+ */
+#define ast_strdupa(s) \
+ (__extension__ \
+ ({ \
+ const char *__old = (s); \
+ size_t __len = strlen(__old) + 1; \
+ char *__new = __builtin_alloca(__len); \
+ memcpy (__new, __old, __len); \
+ __new; \
+ }))
+#endif
+
#else
#error "NEVER INCLUDE astmm.h DIRECTLY!!"
#endif /* _ASTERISK_ASTMM_H */
diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index 3812cb159..4e32d6b32 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -126,6 +126,8 @@ enum ast_rtp_property {
AST_RTP_PROPERTY_RETRANS_RECV,
/*! Enable packet retransmission for sent packets */
AST_RTP_PROPERTY_RETRANS_SEND,
+ /*! Enable REMB sending and receiving passthrough support */
+ AST_RTP_PROPERTY_REMB,
/*!
* \brief Maximum number of RTP properties supported
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index bb9aa2a3c..4da7fa465 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -484,364 +484,6 @@ long int ast_random(void);
#define ast_random_double() (((double)ast_random()) / RAND_MAX)
/*!
- * \brief DEBUG_CHAOS returns failure randomly
- *
- * DEBUG_CHAOS_RETURN(failure); can be used to fake
- * failure of functions such as memory allocation,
- * for the purposes of testing failure handling.
- */
-#ifdef DEBUG_CHAOS
-#ifndef DEBUG_CHAOS_ALLOC_CHANCE
-#define DEBUG_CHAOS_ALLOC_CHANCE 100000
-#endif
-/* Could #define DEBUG_CHAOS_ENABLE ast_fully_booted */
-#ifndef DEBUG_CHAOS_ENABLE
-#define DEBUG_CHAOS_ENABLE 1
-#endif
-#define DEBUG_CHAOS_RETURN(CHANCE, FAILURE) \
- do { \
- if ((DEBUG_CHAOS_ENABLE) && (ast_random() % CHANCE == 0)) { \
- return FAILURE; \
- } \
- } while (0)
-#else
-#define DEBUG_CHAOS_RETURN(c,f)
-#endif
-
-
-#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2)
-void *ast_std_malloc(size_t size);
-void *ast_std_calloc(size_t nmemb, size_t size);
-void *ast_std_realloc(void *ptr, size_t size);
-void ast_std_free(void *ptr);
-
-/*!
- * \brief free() wrapper
- *
- * ast_free_ptr should be used when a function pointer for free() needs to be passed
- * as the argument to a function. Otherwise, astmm will cause seg faults.
- */
-void ast_free_ptr(void *ptr);
-void __ast_free(void *ptr, const char *file, int lineno, const char *func);
-
-#else
-
-/*
- * Need to defeat the MALLOC_DEBUG API when building the standalone utilities.
- */
-
-#define ast_std_malloc malloc
-#define ast_std_calloc calloc
-#define ast_std_realloc realloc
-#define ast_std_free free
-
-#define ast_free_ptr free
-#define ast_free free
-
-#define __ast_repl_calloc(nmemb, size, file, lineno, func) \
- calloc(nmemb, size)
-
-#define __ast_repl_calloc_cache(nmemb, size, file, lineno, func) \
- calloc(nmemb, size)
-
-#define __ast_repl_malloc(size, file, lineno, func) \
- malloc(size)
-
-#define __ast_repl_realloc(ptr, size, file, lineno, func) \
- realloc(ptr, size)
-
-#define __ast_repl_strdup(s, file, lineno, func) \
- strdup(s)
-
-#define __ast_repl_strndup(s, n, file, lineno, func) \
- strndup(s, n)
-
-#define __ast_repl_vasprintf(strp, format, ap, file, lineno, func) \
- vasprintf(strp, format, ap)
-#endif
-
-#if defined(AST_IN_CORE)
-#define MALLOC_FAILURE_MSG \
- ast_log_safe(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file)
-#else
-#define MALLOC_FAILURE_MSG \
- ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file)
-#endif
-
-AST_INLINE_API(
-void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, const char *func),
-{
- void *p;
-
- DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
-
- p = __ast_repl_malloc(len, file, lineno, func);
- if (!p) {
- MALLOC_FAILURE_MSG;
- }
-
- return p;
-}
-)
-
-AST_INLINE_API(
-void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func),
-{
- void *p;
-
- DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
-
- p = __ast_repl_calloc(num, len, file, lineno, func);
- if (!p) {
- MALLOC_FAILURE_MSG;
- }
-
- return p;
-}
-)
-
-AST_INLINE_API(
-void * attribute_malloc __ast_calloc_cache(size_t num, size_t len, const char *file, int lineno, const char *func),
-{
- void *p;
-
- DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
-
- p = __ast_repl_calloc_cache(num, len, file, lineno, func);
- if (!p) {
- MALLOC_FAILURE_MSG;
- }
-
- return p;
-}
-)
-
-AST_INLINE_API(
-void *__ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
-{
- void *newp;
-
- DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
-
- newp = __ast_repl_realloc(p, len, file, lineno, func);
- if (!newp) {
- MALLOC_FAILURE_MSG;
- }
-
- return newp;
-}
-)
-
-AST_INLINE_API(
-char * attribute_malloc __ast_strdup(const char *str, const char *file, int lineno, const char *func),
-{
- char *newstr = NULL;
-
- DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
-
- if (str) {
- newstr = __ast_repl_strdup(str, file, lineno, func);
- if (!newstr) {
- MALLOC_FAILURE_MSG;
- }
- }
-
- return newstr;
-}
-)
-
-AST_INLINE_API(
-char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func),
-{
- char *newstr = NULL;
-
- DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
-
- if (str) {
- newstr = __ast_repl_strndup(str, len, file, lineno, func);
- if (!newstr) {
- MALLOC_FAILURE_MSG;
- }
- }
-
- return newstr;
-}
-)
-
-AST_INLINE_API(
-__attribute__((format(printf, 5, 6)))
-int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...),
-{
- int res;
- va_list ap;
-
- DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1);
-
- va_start(ap, fmt);
- res = __ast_repl_vasprintf(ret, fmt, ap, file, lineno, func);
- if (res < 0) {
- /*
- * *ret is undefined so set to NULL to ensure it is
- * initialized to something useful.
- */
- *ret = NULL;
- MALLOC_FAILURE_MSG;
- }
- va_end(ap);
-
- return res;
-}
-)
-
-AST_INLINE_API(
-__attribute__((format(printf, 2, 0)))
-int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, int lineno, const char *func),
-{
- int res;
-
- DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1);
-
- res = __ast_repl_vasprintf(ret, fmt, ap, file, lineno, func);
- if (res < 0) {
- /*
- * *ret is undefined so set to NULL to ensure it is
- * initialized to something useful.
- */
- *ret = NULL;
- MALLOC_FAILURE_MSG;
- }
-
- return res;
-}
-)
-
-/*!
- * \brief A wrapper for malloc()
- *
- * ast_malloc() is a wrapper for malloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The argument and return value are the same as malloc()
- */
-#define ast_malloc(len) \
- __ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- * \brief A wrapper for calloc()
- *
- * ast_calloc() is a wrapper for calloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as calloc()
- */
-#define ast_calloc(num, len) \
- __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- * \brief A wrapper for calloc() for use in cache pools
- *
- * ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log
- * message in the case that the allocation fails. When memory debugging is in use,
- * the memory allocated by this function will be marked as 'cache' so it can be
- * distinguished from normal memory allocations.
- *
- * The arguments and return value are the same as calloc()
- */
-#define ast_calloc_cache(num, len) \
- __ast_calloc_cache((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- * \brief A wrapper for realloc()
- *
- * ast_realloc() is a wrapper for realloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as realloc()
- */
-#define ast_realloc(p, len) \
- __ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- * \brief A wrapper for strdup()
- *
- * ast_strdup() is a wrapper for strdup() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL
- * argument is provided, ast_strdup will return NULL without generating any
- * kind of error log message.
- *
- * The argument and return value are the same as strdup()
- */
-#define ast_strdup(str) \
- __ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- * \brief A wrapper for strndup()
- *
- * ast_strndup() is a wrapper for strndup() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * ast_strndup(), unlike strndup(), can safely accept a NULL argument for the
- * string to duplicate. If a NULL argument is provided, ast_strdup will return
- * NULL without generating any kind of error log message.
- *
- * The arguments and return value are the same as strndup()
- */
-#define ast_strndup(str, len) \
- __ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- * \brief A wrapper for asprintf()
- *
- * ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as asprintf()
- */
-#define ast_asprintf(ret, fmt, ...) \
- __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__)
-
-/*!
- * \brief A wrapper for vasprintf()
- *
- * ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as vasprintf()
- */
-#define ast_vasprintf(ret, fmt, ap) \
- __ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- \brief call __builtin_alloca to ensure we get gcc builtin semantics
- \param size The size of the buffer we want allocated
-
- This macro will attempt to allocate memory from the stack. If it fails
- you won't get a NULL returned, but a SEGFAULT if you're lucky.
-*/
-#define ast_alloca(size) __builtin_alloca(size)
-
-#if !defined(ast_strdupa) && defined(__GNUC__)
-/*!
- * \brief duplicate a string in memory from the stack
- * \param s The string to duplicate
- *
- * This macro will duplicate the given string. It returns a pointer to the stack
- * allocatted memory for the new string.
- */
-#define ast_strdupa(s) \
- (__extension__ \
- ({ \
- const char *__old = (s); \
- size_t __len = strlen(__old) + 1; \
- char *__new = __builtin_alloca(__len); \
- memcpy (__new, __old, __len); \
- __new; \
- }))
-#endif
-
-/*!
* \brief Disable PMTU discovery on a socket
* \param sock The socket to manipulate
* \return Nothing
diff --git a/main/astmm.c b/main/astmm.c
index 1fa35d728..08f67ab33 100644
--- a/main/astmm.c
+++ b/main/astmm.c
@@ -31,6 +31,40 @@
#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
+#include "asterisk/logger.h"
+
+/*!
+ * \brief DEBUG_CHAOS returns failure randomly
+ *
+ * DEBUG_CHAOS_RETURN(failure); can be used to fake
+ * failure of functions such as memory allocation,
+ * for the purposes of testing failure handling.
+ */
+#ifdef DEBUG_CHAOS
+#ifndef DEBUG_CHAOS_ALLOC_CHANCE
+#define DEBUG_CHAOS_ALLOC_CHANCE 100000
+#endif
+/* Could #define DEBUG_CHAOS_ENABLE ast_fully_booted */
+#ifndef DEBUG_CHAOS_ENABLE
+#define DEBUG_CHAOS_ENABLE 1
+#endif
+#define DEBUG_CHAOS_RETURN(CHANCE, FAILURE) \
+ do { \
+ if ((DEBUG_CHAOS_ENABLE) && (ast_random() % CHANCE == 0)) { \
+ return FAILURE; \
+ } \
+ } while (0)
+#else
+#define DEBUG_CHAOS_RETURN(c,f)
+#endif
+
+#if defined(STANDALONE) || defined(STANDALONE2)
+#define ast_log_safe ast_log
+#endif
+
+#define MALLOC_FAILURE_MSG \
+ ast_log_safe(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file)
+
#if defined(__AST_DEBUG_MALLOC)
#include "asterisk/paths.h" /* use ast_config_AST_LOG_DIR */
@@ -191,6 +225,8 @@ static void *__ast_alloc_region(size_t size, const enum func_type which, const c
unsigned int *fence;
int hash;
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
if (!(reg = malloc(size + sizeof(*reg) + sizeof(*fence)))) {
astmm_log("Memory Allocation Failure - '%d' bytes at %s %s() line %d\n",
(int) size, file, func, lineno);
@@ -425,7 +461,7 @@ static void regions_check_all_fences(void)
ast_mutex_unlock(&reglock);
}
-static void __ast_free_region(void *ptr, const char *file, int lineno, const char *func)
+void __ast_free(void *ptr, const char *file, int lineno, const char *func)
{
struct ast_region *reg;
@@ -466,7 +502,7 @@ void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno,
return ptr;
}
-void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
+static void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
{
void *ptr;
@@ -491,11 +527,6 @@ void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *f
return ptr;
}
-void __ast_free(void *ptr, const char *file, int lineno, const char *func)
-{
- __ast_free_region(ptr, file, lineno, func);
-}
-
/*!
* \note reglock must be locked before calling.
*/
@@ -538,7 +569,7 @@ void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, c
}
if (!size) {
- __ast_free_region(ptr, file, lineno, func);
+ __ast_free(ptr, file, lineno, func);
return NULL;
}
@@ -553,7 +584,7 @@ void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, c
/* Make sure that the added memory is not zero. */
memset(new_mem + len, MALLOC_FILLER, size - len);
}
- __ast_free_region(ptr, file, lineno, func);
+ __ast_free(ptr, file, lineno, func);
} else {
/* Make sure that the malloced memory is not zero. */
memset(new_mem, MALLOC_FILLER, size);
@@ -568,12 +599,10 @@ char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char
size_t len;
void *ptr;
- if (!s)
- return NULL;
-
len = strlen(s) + 1;
- if ((ptr = __ast_alloc_region(len, FUNC_STRDUP, file, lineno, func, 0)))
+ if ((ptr = __ast_alloc_region(len, FUNC_STRDUP, file, lineno, func, 0))) {
strcpy(ptr, s);
+ }
return ptr;
}
@@ -583,10 +612,6 @@ char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno,
size_t len;
char *ptr;
- if (!s) {
- return NULL;
- }
-
len = strnlen(s, n);
if ((ptr = __ast_alloc_region(len + 1, FUNC_STRNDUP, file, lineno, func, 0))) {
memcpy(ptr, s, len);
@@ -601,18 +626,21 @@ int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **s
int size;
va_list ap, ap2;
char s;
+ void *ptr;
- *strp = NULL;
va_start(ap, fmt);
va_copy(ap2, ap);
size = vsnprintf(&s, 1, fmt, ap2);
va_end(ap2);
- if (!(*strp = __ast_alloc_region(size + 1, FUNC_ASPRINTF, file, lineno, func, 0))) {
+ ptr = __ast_alloc_region(size + 1, FUNC_ASPRINTF, file, lineno, func, 0);
+ if (!ptr) {
+ /* As with stdlib *strp is undefined if allocation fails. */
va_end(ap);
return -1;
}
- vsnprintf(*strp, size + 1, fmt, ap);
+ vsnprintf(ptr, size + 1, fmt, ap);
va_end(ap);
+ *strp = ptr;
return size;
}
@@ -622,16 +650,18 @@ int __ast_repl_vasprintf(char **strp, const char *fmt, va_list ap, const char *f
int size;
va_list ap2;
char s;
+ void *ptr;
- *strp = NULL;
va_copy(ap2, ap);
size = vsnprintf(&s, 1, fmt, ap2);
va_end(ap2);
- if (!(*strp = __ast_alloc_region(size + 1, FUNC_VASPRINTF, file, lineno, func, 0))) {
- va_end(ap);
+ ptr = __ast_alloc_region(size + 1, FUNC_VASPRINTF, file, lineno, func, 0);
+ if (!ptr) {
+ /* As with stdlib *strp is undefined if allocation fails. */
return -1;
}
- vsnprintf(*strp, size + 1, fmt, ap);
+ vsnprintf(ptr, size + 1, fmt, ap);
+ *strp = ptr;
return size;
}
@@ -1522,16 +1552,22 @@ void __ast_mm_init_phase_2(void)
void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
{
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
return calloc(nmemb, size);
}
-void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
+static void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
{
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
return calloc(nmemb, size);
}
void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func)
{
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
return malloc(size);
}
@@ -1542,38 +1578,164 @@ void __ast_free(void *ptr, const char *file, int lineno, const char *func)
void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
{
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
return realloc(ptr, size);
}
char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func)
{
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
return strdup(s);
}
char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func)
{
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
return strndup(s, n);
}
int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
{
+ int res;
va_list ap;
- int rc = 0;
+
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1);
va_start(ap, format);
- rc = vasprintf(strp, format, ap);
+ res = vasprintf(strp, format, ap);
va_end(ap);
- return rc;
+ return res;
}
int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
{
+ DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1);
+
return vasprintf(strp, format, ap);
}
#endif /* defined(__AST_DEBUG_MALLOC) */
+void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
+{
+ void *p;
+
+ p = __ast_repl_calloc(nmemb, size, file, lineno, func);
+ if (!p) {
+ MALLOC_FAILURE_MSG;
+ }
+
+ return p;
+}
+
+void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
+{
+ void *p;
+
+ p = __ast_repl_calloc_cache(nmemb, size, file, lineno, func);
+ if (!p) {
+ MALLOC_FAILURE_MSG;
+ }
+
+ return p;
+
+}
+
+void *__ast_malloc(size_t size, const char *file, int lineno, const char *func)
+{
+ void *p;
+
+ p = __ast_repl_malloc(size, file, lineno, func);
+ if (!p) {
+ MALLOC_FAILURE_MSG;
+ }
+
+ return p;
+}
+
+void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
+{
+ void *newp;
+
+ newp = __ast_repl_realloc(ptr, size, file, lineno, func);
+ if (!newp) {
+ MALLOC_FAILURE_MSG;
+ }
+
+ return newp;
+}
+
+char *__ast_strdup(const char *s, const char *file, int lineno, const char *func)
+{
+ char *newstr = NULL;
+
+ if (s) {
+ newstr = __ast_repl_strdup(s, file, lineno, func);
+ if (!newstr) {
+ MALLOC_FAILURE_MSG;
+ }
+ }
+
+ return newstr;
+}
+
+char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func)
+{
+ char *newstr = NULL;
+
+ if (s) {
+ newstr = __ast_repl_strndup(s, n, file, lineno, func);
+ if (!newstr) {
+ MALLOC_FAILURE_MSG;
+ }
+ }
+
+ return newstr;
+}
+
+int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
+{
+ int res;
+ va_list ap;
+
+ va_start(ap, format);
+ res = __ast_repl_vasprintf(strp, format, ap, file, lineno, func);
+ if (res < 0) {
+ /*
+ * *strp is undefined so set to NULL to ensure it is
+ * initialized to something useful.
+ */
+ *strp = NULL;
+
+ MALLOC_FAILURE_MSG;
+ }
+ va_end(ap);
+
+ return res;
+}
+
+int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
+{
+ int res;
+
+ res = __ast_repl_vasprintf(strp, format, ap, file, lineno, func);
+ if (res < 0) {
+ /*
+ * *strp is undefined so set to NULL to ensure it is
+ * initialized to something useful.
+ */
+ *strp = NULL;
+
+ MALLOC_FAILURE_MSG;
+ }
+
+ return res;
+}
+
void *ast_std_malloc(size_t size)
{
return malloc(size);
diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index 9f0cdd300..03d37652f 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -222,6 +222,7 @@ static int create_rtp(struct ast_sip_session *session, struct ast_sip_session_me
} else if (session_media->type == AST_MEDIA_TYPE_VIDEO) {
ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_RETRANS_RECV, session->endpoint->media.webrtc);
ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_RETRANS_SEND, session->endpoint->media.webrtc);
+ ast_rtp_instance_set_prop(session_media->rtp, AST_RTP_PROPERTY_REMB, session->endpoint->media.webrtc);
if (session->endpoint->media.tos_video || session->endpoint->media.cos_video) {
ast_rtp_instance_set_qos(session_media->rtp, session->endpoint->media.tos_video,
session->endpoint->media.cos_video, "SIP RTP Video");
@@ -1092,6 +1093,9 @@ static void add_rtcp_fb_to_stream(struct ast_sip_session *session,
*/
attr = pjmedia_sdp_attr_create(pool, "rtcp-fb", pj_cstr(&stmp, "* ccm fir"));
pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
+
+ attr = pjmedia_sdp_attr_create(pool, "rtcp-fb", pj_cstr(&stmp, "* goog-remb"));
+ pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
}
/*! \brief Function which negotiates an incoming media stream */
diff --git a/third-party/pjproject/patches/asterisk_malloc_debug.h b/third-party/pjproject/patches/asterisk_malloc_debug.h
index e5e04f1af..2a502fa40 100644
--- a/third-party/pjproject/patches/asterisk_malloc_debug.h
+++ b/third-party/pjproject/patches/asterisk_malloc_debug.h
@@ -25,14 +25,24 @@
extern "C" {
#endif
+#ifndef attribute_malloc
+#ifdef HAVE_ATTRIBUTE_malloc
+/* HAVE_ATTRIBUTE_malloc is never defined from pjproject. This is here as a placeholder
+ * hopefully we can just use __attribute__((malloc)) unconditionally. */
+#define attribute_malloc __attribute__((malloc))
+#else
+#define attribute_malloc
+#endif
+#endif
+
int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
__attribute__((format(printf, 5, 6)));
-void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
+void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc;
void __ast_free(void *ptr, const char *file, int lineno, const char *func);
-void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func);
+void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc;
void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
-char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func);
-char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
+char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func) attribute_malloc;
+char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc;
int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
__attribute__((format(printf, 2, 0)));
@@ -47,29 +57,29 @@ int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char
#undef vasprintf
/* Provide our own definitions */
-#define asprintf(a, b, c...) \
- __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
+#define asprintf(strp, format, args...) \
+ __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, strp, format, args)
-#define calloc(a,b) \
- __ast_repl_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define calloc(nmemb, size) \
+ __ast_repl_calloc(nmemb, size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define free(a) \
- __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define free(ptr) \
+ __ast_free(ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define malloc(a) \
- __ast_repl_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define malloc(size) \
+ __ast_repl_malloc(size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define realloc(a,b) \
- __ast_repl_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define realloc(ptr, size) \
+ __ast_repl_realloc(ptr, size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define strdup(a) \
- __ast_repl_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define strdup(s) \
+ __ast_repl_strdup(s, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define strndup(a,b) \
- __ast_repl_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define strndup(s, n) \
+ __ast_repl_strndup(s, n, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define vasprintf(a,b,c) \
- __ast_repl_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define vasprintf(strp, format, ap) \
+ __ast_repl_vasprintf(strp, format, ap, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#ifdef __cplusplus
}
diff --git a/utils/.gitignore b/utils/.gitignore
index dbdc6b6d2..7840265e5 100644
--- a/utils/.gitignore
+++ b/utils/.gitignore
@@ -3,6 +3,7 @@ aelparse
aelparse.c
ast_expr2.c
ast_expr2f.c
+astmm.c
astman
astcanary
astdb2bdb
diff --git a/utils/Makefile b/utils/Makefile
index 3a1275407..d62d45f4f 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -86,7 +86,7 @@ clean:
rm -f *.o $(ALL_UTILS) check_expr
rm -f .*.d
rm -f *.s *.i
- rm -f md5.c strcompat.c ast_expr2.c ast_expr2.h ast_expr2f.c pbx_ael.c pval.c hashtab.c lock.c
+ rm -f astmm.c md5.c strcompat.c ast_expr2.c ast_expr2.h ast_expr2f.c pbx_ael.c pval.c hashtab.c lock.c
rm -f aelparse.c aelbison.c conf2ael
rm -f threadstorage.c
rm -f utils.c strings.c poll.c version.c sha1.c astobj2.c refcounter
@@ -100,11 +100,14 @@ md5.c: $(ASTTOPDIR)/main/md5.c
astman: astman.o md5.o
astman: LIBS+=$(NEWT_LIB)
-astman.o: _ASTCFLAGS+=-DNO_MALLOC_DEBUG
stereorize: stereorize.o frame.o
stereorize: LIBS+=-lm
+astmm.c: $(ASTTOPDIR)/main/astmm.c
+ $(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
+ $(CMD_PREFIX) cp "$<" "$@"
+
hashtab.c: $(ASTTOPDIR)/main/hashtab.c
$(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
$(CMD_PREFIX) cp "$<" "$@"
@@ -134,7 +137,7 @@ ast_expr2f.c: $(ASTTOPDIR)/main/ast_expr2f.c
$(CMD_PREFIX) cp "$<" "$@"
ast_expr2f.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/main -Wno-unused
-check_expr: check_expr.o ast_expr2.o ast_expr2f.o strcompat.o threadstorage.o clicompat.o
+check_expr: check_expr.o ast_expr2.o ast_expr2f.o strcompat.o threadstorage.o clicompat.o astmm.o
aelbison.c: $(ASTTOPDIR)/res/ael/ael.tab.c
$(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
@@ -162,7 +165,7 @@ aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c
aelparse.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res -Wno-unused
aelparse: LIBS+=-lm
-aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o lock.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o
+aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o lock.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o astmm.o
threadstorage.c: $(ASTTOPDIR)/main/threadstorage.c
$(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
@@ -171,15 +174,15 @@ threadstorage.c: $(ASTTOPDIR)/main/threadstorage.c
extconf.o: extconf.c
-conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o lock.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o
+conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o lock.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o astmm.o
-check_expr2: $(ASTTOPDIR)/main/ast_expr2f.c $(ASTTOPDIR)/main/ast_expr2.c $(ASTTOPDIR)/main/ast_expr2.h
+check_expr2: $(ASTTOPDIR)/main/ast_expr2f.c $(ASTTOPDIR)/main/ast_expr2.c $(ASTTOPDIR)/main/ast_expr2.h astmm.o
$(ECHO_PREFIX) echo " [CC] ast_expr2f.c -> ast_expr2fz.o"
$(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE $(ASTTOPDIR)/main/ast_expr2f.c -o ast_expr2fz.o
$(ECHO_PREFIX) echo " [CC] ast_expr2.c -> ast_expr2z.o"
$(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE2 $(ASTTOPDIR)/main/ast_expr2.c -o ast_expr2z.o
$(ECHO_PREFIX) echo " [LD] ast_expr2fz.o ast_expr2z.o -> check_expr2"
- $(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.o -lm
+ $(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.o astmm.o -lm
$(ECHO_PREFIX) echo " [RM] ast_expr2fz.o ast_expr2z.o"
rm ast_expr2z.o ast_expr2fz.o
./check_expr2 expr2.testinput
diff --git a/utils/ael_main.c b/utils/ael_main.c
index 3a91ef167..f4521e183 100644
--- a/utils/ael_main.c
+++ b/utils/ael_main.c
@@ -11,6 +11,7 @@
<support_level>extended</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include <locale.h>
diff --git a/utils/astman.c b/utils/astman.c
index af3185104..d4757d026 100644
--- a/utils/astman.c
+++ b/utils/astman.c
@@ -26,6 +26,7 @@
<support_level>extended</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include <newt.h>
diff --git a/utils/check_expr.c b/utils/check_expr.c
index 1e4b9d175..d4a4c900f 100644
--- a/utils/check_expr.c
+++ b/utils/check_expr.c
@@ -20,6 +20,7 @@
<support_level>extended</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include "asterisk/ast_expr.h"
diff --git a/utils/conf2ael.c b/utils/conf2ael.c
index a8371bbec..e3a905690 100644
--- a/utils/conf2ael.c
+++ b/utils/conf2ael.c
@@ -27,6 +27,7 @@
<support_level>extended</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include "asterisk/paths.h" /* CONFIG_DIR */
diff --git a/utils/extconf.c b/utils/extconf.c
index 6826f4f99..541cbf800 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -43,7 +43,7 @@
<support_level>extended</support_level>
***/
-#define ASTMM_LIBC ASTMM_REDIRECT
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#undef DEBUG_THREADS
@@ -681,9 +681,6 @@ int ast_channel_trylock(struct ast_channel *chan);
/* from utils.h */
-#define ast_free free
-#define ast_free_ptr free
-
struct ast_flags { /* stolen from utils.h */
unsigned int flags;
};
@@ -704,222 +701,6 @@ struct ast_flags { /* stolen from utils.h */
(p)->flags &= ~(flag); \
} while (0)
-
-
-#define MALLOC_FAILURE_MSG \
- ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
-
-/*!
- * \brief A wrapper for malloc()
- *
- * ast_malloc() is a wrapper for malloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The argument and return value are the same as malloc()
- */
-#define ast_malloc(len) \
- __ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, const char *func),
-{
- void *p;
-
- if (!(p = malloc(len)))
- MALLOC_FAILURE_MSG;
-
- return p;
-}
-)
-
-/*!
- * \brief A wrapper for calloc()
- *
- * ast_calloc() is a wrapper for calloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as calloc()
- */
-#define ast_calloc(num, len) \
- __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func),
-{
- void *p;
-
- if (!(p = calloc(num, len)))
- MALLOC_FAILURE_MSG;
-
- return p;
-}
-)
-
-/*!
- * \brief A wrapper for calloc() for use in cache pools
- *
- * ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log
- * message in the case that the allocation fails. When memory debugging is in use,
- * the memory allocated by this function will be marked as 'cache' so it can be
- * distinguished from normal memory allocations.
- *
- * The arguments and return value are the same as calloc()
- */
-#define ast_calloc_cache(num, len) \
- __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- * \brief A wrapper for realloc()
- *
- * ast_realloc() is a wrapper for realloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as realloc()
- */
-#define ast_realloc(p, len) \
- __ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-void *__ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
-{
- void *newp;
-
- if (!(newp = realloc(p, len)))
- MALLOC_FAILURE_MSG;
-
- return newp;
-}
-)
-
-/*!
- * \brief A wrapper for strdup()
- *
- * ast_strdup() is a wrapper for strdup() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL
- * argument is provided, ast_strdup will return NULL without generating any
- * kind of error log message.
- *
- * The argument and return value are the same as strdup()
- */
-#define ast_strdup(str) \
- __ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-char * attribute_malloc __ast_strdup(const char *str, const char *file, int lineno, const char *func),
-{
- char *newstr = NULL;
-
- if (str) {
- if (!(newstr = strdup(str)))
- MALLOC_FAILURE_MSG;
- }
-
- return newstr;
-}
-)
-
-/*!
- * \brief A wrapper for strndup()
- *
- * ast_strndup() is a wrapper for strndup() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * ast_strndup(), unlike strndup(), can safely accept a NULL argument for the
- * string to duplicate. If a NULL argument is provided, ast_strdup will return
- * NULL without generating any kind of error log message.
- *
- * The arguments and return value are the same as strndup()
- */
-#define ast_strndup(str, len) \
- __ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func),
-{
- char *newstr = NULL;
-
- if (str) {
- if (!(newstr = strndup(str, len)))
- MALLOC_FAILURE_MSG;
- }
-
- return newstr;
-}
-)
-
-/*!
- * \brief A wrapper for asprintf()
- *
- * ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as asprintf()
- */
-#define ast_asprintf(ret, fmt, ...) \
- __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__)
-
-AST_INLINE_API(
-__attribute__((format(printf, 5, 6)))
-int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...),
-{
- int res;
- va_list ap;
-
- va_start(ap, fmt);
- if ((res = vasprintf(ret, fmt, ap)) == -1)
- MALLOC_FAILURE_MSG;
- va_end(ap);
-
- return res;
-}
-)
-
-/*!
- * \brief A wrapper for vasprintf()
- *
- * ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as vasprintf()
- */
-#define ast_vasprintf(ret, fmt, ap) \
- __ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-__attribute__((format(printf, 2, 0)))
-int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, int lineno, const char *func),
-{
- int res;
-
- if ((res = vasprintf(ret, fmt, ap)) == -1)
- MALLOC_FAILURE_MSG;
-
- return res;
-}
-)
-
-#if !defined(ast_strdupa) && defined(__GNUC__)
-/*!
- \brief duplicate a string in memory from the stack
- \param s The string to duplicate
-
- This macro will duplicate the given string. It returns a pointer to the stack
- allocatted memory for the new string.
-*/
-#define ast_strdupa(s) \
- (__extension__ \
- ({ \
- const char *__old = (s); \
- size_t __len = strlen(__old) + 1; \
- char *__new = __builtin_alloca(__len); \
- memcpy (__new, __old, __len); \
- __new; \
- }))
-#endif
-
-
/* from config.c */
#define MAX_NESTED_COMMENTS 128