summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES7
-rw-r--r--Makefile8
-rw-r--r--UPGRADE.txt6
-rw-r--r--apps/app_dial.c2
-rw-r--r--apps/app_voicemail.c36
-rwxr-xr-xbuild_tools/make_buildopts_h17
-rwxr-xr-xconfigure284
-rw-r--r--configure.ac72
-rwxr-xr-xcontrib/scripts/install_prereq108
-rw-r--r--include/asterisk.h2
-rw-r--r--include/asterisk/astmm.h67
-rw-r--r--include/asterisk/autoconfig.h.in2
-rw-r--r--include/asterisk/channel.h4
-rw-r--r--include/asterisk/chanvars.h8
-rw-r--r--include/asterisk/compat.h6
-rw-r--r--include/asterisk/config.h5
-rw-r--r--include/asterisk/datastore.h2
-rw-r--r--include/asterisk/hashtab.h67
-rw-r--r--include/asterisk/heap.h15
-rw-r--r--include/asterisk/stringfields.h6
-rw-r--r--include/asterisk/strings.h69
-rw-r--r--include/asterisk/utils.h113
-rw-r--r--main/astmm.c120
-rw-r--r--main/astobj2_container.c29
-rw-r--r--main/ccss.c17
-rw-r--r--main/cdr.c11
-rw-r--r--main/channel.c14
-rw-r--r--main/chanvars.c12
-rw-r--r--main/cli.c24
-rw-r--r--main/config.c14
-rw-r--r--main/datastore.c3
-rw-r--r--main/hashtab.c136
-rw-r--r--main/heap.c45
-rw-r--r--main/pbx_app.c27
-rw-r--r--main/strcompat.c13
-rw-r--r--main/stringfields.c39
-rw-r--r--main/strings.c16
-rw-r--r--main/utils.c22
-rw-r--r--menuselect/strcompat.c12
-rw-r--r--res/res_pjsip_rfc3326.c41
-rw-r--r--res/res_srtp.c1
-rw-r--r--res/stasis_recording/stored.c11
-rw-r--r--sounds/Makefile6
-rw-r--r--third-party/pjproject/Makefile4
-rw-r--r--third-party/pjproject/configure.m42
-rw-r--r--third-party/pjproject/patches/asterisk_malloc_debug.c14
-rw-r--r--third-party/pjproject/patches/asterisk_malloc_debug.h28
-rw-r--r--third-party/pjproject/patches/config_site.h2
-rw-r--r--utils/extconf.c2
49 files changed, 836 insertions, 735 deletions
diff --git a/CHANGES b/CHANGES
index 37ec31931..0f4ced2af 100644
--- a/CHANGES
+++ b/CHANGES
@@ -17,6 +17,13 @@ app_fax
* The app_fax module is now deprecated, users should migrate to the
replacement module res_fax.
+Build System
+------------------
+ * MALLOC_DEBUG no longer has an effect on Asterisk's ABI. Asterisk built
+ with MALLOC_DEBUG can now successfully load binary modules built without
+ MALLOC_DEBUG and vice versa. Third-party pre-compiled modules no longer
+ need to have a special build with it enabled.
+
app_macro
------------------
* The app_macro module is now deprecated and by default it is no longer
diff --git a/Makefile b/Makefile
index e624abf77..54368f7c6 100644
--- a/Makefile
+++ b/Makefile
@@ -217,7 +217,9 @@ ifeq ($(AST_DEVMODE),yes)
endif
endif
-ifneq ($(findstring BSD,$(OSARCH)),)
+ifeq ($(OSARCH),NetBSD)
+ _ASTCFLAGS+=-isystem /usr/pkg/include
+else ifneq ($(findstring BSD,$(OSARCH)),)
_ASTCFLAGS+=-isystem /usr/local/include
endif
@@ -284,7 +286,9 @@ else
# These are used for all but Darwin
SOLINK=-shared
DYLINK=$(SOLINK)
- ifneq ($(findstring BSD,$(OSARCH)),)
+ ifeq ($(OSARCH),NetBSD)
+ _ASTLDFLAGS+=-L/usr/pkg/lib
+ else ifneq ($(findstring BSD,$(OSARCH)),)
_ASTLDFLAGS+=-L/usr/local/lib
endif
endif
diff --git a/UPGRADE.txt b/UPGRADE.txt
index 366825863..108c10a01 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -44,6 +44,12 @@ ARI:
- The ContactInfo event's contact_status field is now set to "NonQualified"
when a contact exists but has not been qualified.
+Build System:
+ - MALLOC_DEBUG no longer has an effect on Asterisk's ABI. Asterisk built
+ with MALLOC_DEBUG can now successfully load binary modules built without
+ MALLOC_DEBUG and vice versa. Third-party pre-compiled modules no longer
+ need to have a special build with it enabled.
+
cdr_syslog:
- The cdr_syslog module is now deprecated and by default it is no longer
built.
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 9d6f5beaf..3d16fb6a1 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1605,6 +1605,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
break;
}
break;
+ case AST_FRAME_VIDEO:
case AST_FRAME_VOICE:
case AST_FRAME_IMAGE:
if (caller_entertained) {
@@ -1703,6 +1704,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
ast_log(LOG_WARNING, "Unable to send URL\n");
}
break;
+ case AST_FRAME_VIDEO:
case AST_FRAME_VOICE:
case AST_FRAME_IMAGE:
if (!single || caller_entertained) {
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 82fa3b341..1ab1169d5 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -7872,7 +7872,8 @@ static int get_folder2(struct ast_channel *chan, char *fn, int start)
ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", '#', '#');
return '#';
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(res) ? res : '?', isprint(res) ? res : '?');
return res;
}
@@ -8035,7 +8036,8 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
if (retries > 3) {
cmd = '*'; /* Let's cancel this beast */
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
}
}
@@ -8263,7 +8265,8 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
cmd = 't';
done = 1;
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
}
}
if (cmd < 0 || cmd == 't')
@@ -8928,7 +8931,8 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc
ast_log(AST_LOG_WARNING, "Playback of message %s failed\n", vms->fn);
res = 0;
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(res) ? res : '?', isprint(res) ? res : '?');
}
DISPOSE(vms->curdir, vms->curmsg);
return res;
@@ -10783,7 +10787,8 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct
if (retries > 3) {
cmd = 't';
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
}
}
if (cmd == 't')
@@ -10863,7 +10868,8 @@ static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, st
if (retries > 3) {
cmd = 't';
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
}
}
DISPOSE(prefile, -1);
@@ -11685,7 +11691,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data)
} else {
cmd = vm_intro(chan, vmu, &vms);
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
vms.repeats = 0;
vms.starting = 1;
@@ -11705,7 +11712,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data)
adsi_folders(chan, 0, "Change to folder...");
cmd = get_folder2(chan, "vm-changeto", 0);
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
if (cmd == '#') {
cmd = 0;
} else if (cmd > 0) {
@@ -11837,7 +11845,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data)
if (vms.repeats > 3) {
cmd = 't';
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
}
}
if (cmd == 't') {
@@ -12015,7 +12024,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data)
if (useadsi)
adsi_folders(chan, 1, "Save to folder...");
cmd = get_folder2(chan, "vm-savefolder", 1);
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
box = 0; /* Shut up compiler */
if (cmd == '#') {
cmd = 0;
@@ -15181,7 +15191,8 @@ static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num,
else
cmd = 't';
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", cmd, cmd);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(cmd) ? cmd : '?', isprint(cmd) ? cmd : '?');
}
if (retries >= 3) {
return 0;
@@ -15346,7 +15357,8 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
res = 't';
}
}
- ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c", res, res);
+ ast_test_suite_event_notify("USERPRESS", "Message: User pressed %c\r\nDTMF: %c",
+ isprint(res) ? res : '?', isprint(res) ? res : '?');
break;
}
diff --git a/build_tools/make_buildopts_h b/build_tools/make_buildopts_h
index 3ba4cb9dd..c47d5082c 100755
--- a/build_tools/make_buildopts_h
+++ b/build_tools/make_buildopts_h
@@ -20,18 +20,19 @@ fi
TMP=`${GREP} -e "^MENUSELECT_CFLAGS" menuselect.makeopts | sed 's/MENUSELECT_CFLAGS\=//g' | sed 's/-D//g'`
for x in ${TMP}; do
echo "#define ${x} 1"
- if test "${x}" = "DONT_OPTIMIZE" \
+ if test "${x}" = "AO2_DEBUG" \
-o "${x}" = "BETTER_BACKTRACES" \
- -o "${x}" = "LOTS_OF_SPANS" \
-o "${x}" = "BUILD_NATIVE" \
- -o "${x}" = "LOW_MEMORY" \
- -o "${x}" = "REF_DEBUG" \
- -o "${x}" = "AO2_DEBUG" \
- -o "${x}" = "REBUILD_PARSERS" \
- -o "${x}" = "RADIO_RELAX" \
-o "${x}" = "DEBUG_SCHEDULER" \
-o "${x}" = "DETECT_DEADLOCKS" \
- -o "${x}" = "DUMP_SCHEDULER" ; then
+ -o "${x}" = "DONT_OPTIMIZE" \
+ -o "${x}" = "DUMP_SCHEDULER" \
+ -o "${x}" = "LOTS_OF_SPANS" \
+ -o "${x}" = "LOW_MEMORY" \
+ -o "${x}" = "MALLOC_DEBUG" \
+ -o "${x}" = "RADIO_RELAX" \
+ -o "${x}" = "REBUILD_PARSERS" \
+ -o "${x}" = "REF_DEBUG" ; then
# These aren't ABI affecting options, keep them out of AST_BUILDOPTS
continue
fi
diff --git a/configure b/configure
index 9add31da4..e5b9f9e9d 100755
--- a/configure
+++ b/configure
@@ -657,6 +657,8 @@ GMIME_LIBS
GMIME_CFLAGS
PBX_SSL_OP_NO_TLSV1_2
PBX_SSL_OP_NO_TLSV1_1
+PORTAUDIO_LIBS
+PORTAUDIO_CFLAGS
PYTHONDEV_LIBS
PYTHONDEV_CFLAGS
PYTHONDEV_INCLUDE
@@ -1485,6 +1487,8 @@ PJPROJECT_CFLAGS
PJPROJECT_LIBS
PYTHONDEV_CFLAGS
PYTHONDEV_LIBS
+PORTAUDIO_CFLAGS
+PORTAUDIO_LIBS
GMIME_CFLAGS
GMIME_LIBS
GTK2_CFLAGS
@@ -2244,6 +2248,10 @@ Some influential environment variables:
C compiler flags for PYTHONDEV, overriding pkg-config
PYTHONDEV_LIBS
linker flags for PYTHONDEV, overriding pkg-config
+ PORTAUDIO_CFLAGS
+ C compiler flags for PORTAUDIO, overriding pkg-config
+ PORTAUDIO_LIBS
+ linker flags for PORTAUDIO, overriding pkg-config
GMIME_CFLAGS
C compiler flags for GMIME, overriding pkg-config
GMIME_LIBS linker flags for GMIME, overriding pkg-config
@@ -4671,6 +4679,11 @@ case "${host_os}" in
esac
case "${host_os}" in
+ netbsd*)
+ ac_default_prefix=/usr/pkg
+ CPPFLAGS=-I/usr/pkg/include
+ LDFLAGS=-L/usr/pkg/lib
+ ;;
freebsd*)
ac_default_prefix=/usr/local
CPPFLAGS=-I/usr/local/include
@@ -7803,6 +7816,9 @@ fi
+DOWNLOAD=":"
+DOWNLOAD_TO_STDOUT=
+DOWNLOAD_TIMEOUT=
if test "${WGET}" != ":" ; then
DOWNLOAD=${WGET}
DOWNLOAD_TO_STDOUT="${WGET} -q -O-"
@@ -7853,16 +7869,17 @@ $as_echo "no" >&6; }
fi
- DOWNLOAD=${FETCH}
- DOWNLOAD_TO_STDOUT="${FETCH} -o-"
- DOWNLOAD_TIMEOUT='--timeout=$(or $2,$1)'
+ if test "${FETCH}" != ":" ; then
+ DOWNLOAD=${FETCH}
+ DOWNLOAD_TO_STDOUT="${FETCH} -o-"
+ DOWNLOAD_TIMEOUT='--timeout=$(or $2,$1)'
+ fi
fi
fi
-
# Extract the first word of "ldconfig", so it can be a program name with args.
set dummy ldconfig; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -9191,7 +9208,7 @@ $as_echo_n "checking for embedded pjproject (may have to download)... " >&6; }
$as_echo "configuring" >&6; }
if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then
- as_fn_error $? "A download utility (wget, curl or fetch) is required to download bundled pjproject" "$LINENO" 5
+ as_fn_error $? "A download utility (wget, curl, or fetch) is required to download bundled pjproject" "$LINENO" 5
fi
if test "${BZIP2}" = ":" ; then
as_fn_error $? "bzip2 is required to extract the pjproject tar file" "$LINENO" 5
@@ -13882,6 +13899,10 @@ _ACEOF
fi
+if test "x$LIBUUID_LIB" != "x" ; then
+ UUID_INCLUDE="$LIBUUID_INCLUDE"
+ UUID_LIB="$LIBUUID_LIB"
+else
if test "x${PBX_E2FSUUID}" != "x1" -a "${USE_E2FSUUID}" != "no"; then
pbxlibdir=""
@@ -13978,7 +13999,11 @@ _ACEOF
fi
-for ac_func in uuid_generate_random
+ if test "x$E2FSUUID_LIB" != "x" ; then
+ UUID_INCLUDE="$E2FSUUID_INCLUDE"
+ UUID_LIB="$E2FSUUID_LIB"
+ else
+ for ac_func in uuid_generate_random
do :
ac_fn_c_check_func "$LINENO" "uuid_generate_random" "ac_cv_func_uuid_generate_random"
if test "x$ac_cv_func_uuid_generate_random" = xyes; then :
@@ -13991,18 +14016,13 @@ else
fi
done
-
-if test "x$LIBUUID_LIB" != "x" ; then
- UUID_INCLUDE="$LIBUUID_INCLUDE"
- UUID_LIB="$LIBUUID_LIB"
-elif test "x$E2FSUUID_LIB" != "x" ; then
- UUID_INCLUDE="$E2FSUUID_INCLUDE"
- UUID_LIB="$E2FSUUID_LIB"
-elif test "x$SYSUUID" != "x" ; then
- UUID_INCLUDE=""
- UUID_LIB=""
-else
- as_fn_error $? "*** uuid support not found (this typically means the uuid development package is missing)" "$LINENO" 5
+ if test "x$SYSUUID" != "x" ; then
+ UUID_INCLUDE=""
+ UUID_LIB=""
+ else
+ as_fn_error $? "*** uuid support not found (this typically means the uuid development package is missing)" "$LINENO" 5
+ fi
+ fi
fi
@@ -18623,6 +18643,9 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use rpath" >&5
$as_echo_n "checking whether to use rpath... " >&6; }
AST_RPATH=
+if test "${OSARCH}" = "NetBSD"; then
+ AST_RPATH="-Wl,-rpath,/usr/pkg/lib"
+fi
if test "${check_rpath}" != yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: skipped" >&5
$as_echo "skipped" >&6; }
@@ -19444,6 +19467,41 @@ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=${old_LIBS}
+# re-check without -ldl
+# Non-Linux platforms like FreeBSD and NetBSD do not need a library libdl.so.
+if test "${PBX_DLADDR}" = "0"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dladdr in dlfcn.h without -ldl" >&5
+$as_echo_n "checking for dladdr in dlfcn.h without -ldl... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _GNU_SOURCE 1
+#include <dlfcn.h>
+int
+main ()
+{
+dladdr((void *)0, (void *)0)
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ PBX_DLADDR=1
+
+
+$as_echo "#define HAVE_DLADDR 1" >>confdefs.h
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
# PKGCONFIG is used in later tests
@@ -21707,7 +21765,7 @@ $as_echo_n "checking for system c-client library...... " >&6; }
CPPFLAGS="${saved_cppflags}"
LIBS="${saved_libs}"
imap_ldflags=""
- imap_libs="-lc-client"
+ imap_libs="-lcrypto -lssl -lc-client"
imap_include="-DUSE_SYSTEM_IMAP" #Try the imap directory first
CPPFLAGS="${CPPFLAGS} ${imap_include}"
LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
@@ -26337,6 +26395,94 @@ fi
+ if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PORTAUDIO" >&5
+$as_echo_n "checking for PORTAUDIO... " >&6; }
+
+if test -n "$PORTAUDIO_CFLAGS"; then
+ pkg_cv_PORTAUDIO_CFLAGS="$PORTAUDIO_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"portaudio-2.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "portaudio-2.0") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_PORTAUDIO_CFLAGS=`$PKG_CONFIG --cflags "portaudio-2.0" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+if test -n "$PORTAUDIO_LIBS"; then
+ pkg_cv_PORTAUDIO_LIBS="$PORTAUDIO_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"portaudio-2.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "portaudio-2.0") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_PORTAUDIO_LIBS=`$PKG_CONFIG --libs "portaudio-2.0" 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
+ PORTAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "portaudio-2.0" 2>&1`
+ else
+ PORTAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "portaudio-2.0" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$PORTAUDIO_PKG_ERRORS" >&5
+
+
+ PBX_PORTAUDIO=0
+
+
+elif test $pkg_failed = untried; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+ PBX_PORTAUDIO=0
+
+
+else
+ PORTAUDIO_CFLAGS=$pkg_cv_PORTAUDIO_CFLAGS
+ PORTAUDIO_LIBS=$pkg_cv_PORTAUDIO_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+ PBX_PORTAUDIO=1
+ PORTAUDIO_INCLUDE="$PORTAUDIO_CFLAGS"
+ PORTAUDIO_LIB="$PORTAUDIO_LIBS"
+
+$as_echo "#define HAVE_PORTAUDIO 1" >>confdefs.h
+
+
+fi
+ fi
+
+
if test "x${PBX_PORTAUDIO}" != "x1" -a "${USE_PORTAUDIO}" != "no"; then
pbxlibdir=""
# if --with-PORTAUDIO=DIR has been specified, use it.
@@ -33175,105 +33321,6 @@ fi
-if test "${OSARCH}" = "OpenBSD";
-then
-
-if test "x${PBX_VORBIS}" != "x1" -a "${USE_VORBIS}" != "no"; then
- pbxlibdir=""
- # if --with-VORBIS=DIR has been specified, use it.
- if test "x${VORBIS_DIR}" != "x"; then
- if test -d ${VORBIS_DIR}/lib; then
- pbxlibdir="-L${VORBIS_DIR}/lib"
- else
- pbxlibdir="-L${VORBIS_DIR}"
- fi
- fi
-
- ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
- CFLAGS="${CFLAGS} "
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vorbis_info_init in -lvorbis" >&5
-$as_echo_n "checking for vorbis_info_init in -lvorbis... " >&6; }
-if ${ac_cv_lib_vorbis_vorbis_info_init+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lvorbis ${pbxlibdir} -lm -lvorbisenc -lvorbisfile -logg $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char vorbis_info_init ();
-int
-main ()
-{
-return vorbis_info_init ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_vorbis_vorbis_info_init=yes
-else
- ac_cv_lib_vorbis_vorbis_info_init=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vorbis_vorbis_info_init" >&5
-$as_echo "$ac_cv_lib_vorbis_vorbis_info_init" >&6; }
-if test "x$ac_cv_lib_vorbis_vorbis_info_init" = xyes; then :
- AST_VORBIS_FOUND=yes
-else
- AST_VORBIS_FOUND=no
-fi
-
- CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
-
-
- # now check for the header.
- if test "${AST_VORBIS_FOUND}" = "yes"; then
- VORBIS_LIB="${pbxlibdir} -lvorbis -lm -lvorbisenc -lvorbisfile -logg"
- # if --with-VORBIS=DIR has been specified, use it.
- if test "x${VORBIS_DIR}" != "x"; then
- VORBIS_INCLUDE="-I${VORBIS_DIR}/include"
- fi
- VORBIS_INCLUDE="${VORBIS_INCLUDE} "
-
- # check for the header
- ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
- CPPFLAGS="${CPPFLAGS} ${VORBIS_INCLUDE}"
- ac_fn_c_check_header_mongrel "$LINENO" "vorbis/codec.h" "ac_cv_header_vorbis_codec_h" "$ac_includes_default"
-if test "x$ac_cv_header_vorbis_codec_h" = xyes; then :
- VORBIS_HEADER_FOUND=1
-else
- VORBIS_HEADER_FOUND=0
-fi
-
-
- CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-
- if test "x${VORBIS_HEADER_FOUND}" = "x0" ; then
- VORBIS_LIB=""
- VORBIS_INCLUDE=""
- else
-
- PBX_VORBIS=1
- cat >>confdefs.h <<_ACEOF
-#define HAVE_VORBIS 1
-_ACEOF
-
- fi
- fi
-fi
-
-
-else
if test "x${PBX_VORBIS}" != "x1" -a "${USE_VORBIS}" != "no"; then
pbxlibdir=""
@@ -33370,7 +33417,6 @@ _ACEOF
fi
-fi
if test "x${PBX_VORBIS_OPEN_CALLBACKS}" != "x1" -a "${USE_VORBIS_OPEN_CALLBACKS}" != "no"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OV_CALLBACKS_NOCLOSE declared in vorbis/vorbisfile.h" >&5
diff --git a/configure.ac b/configure.ac
index 893489ac3..3151f8995 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,11 @@ case "${host_os}" in
esac
case "${host_os}" in
+ netbsd*)
+ ac_default_prefix=/usr/pkg
+ CPPFLAGS=-I/usr/pkg/include
+ LDFLAGS=-L/usr/pkg/lib
+ ;;
freebsd*)
ac_default_prefix=/usr/local
CPPFLAGS=-I/usr/local/include
@@ -281,6 +286,9 @@ AC_PATH_PROG([PATCH], [patch], :)
AC_PATH_PROG([SED], [sed], :)
AC_PATH_PROG([NM], [nm], :)
+DOWNLOAD=":"
+DOWNLOAD_TO_STDOUT=
+DOWNLOAD_TIMEOUT=
if test "${WGET}" != ":" ; then
DOWNLOAD=${WGET}
DOWNLOAD_TO_STDOUT="${WGET} -q -O-"
@@ -290,13 +298,14 @@ else if test "${CURL}" != ":" ; then
DOWNLOAD_TO_STDOUT="${CURL} -Ls"
DOWNLOAD_TIMEOUT='--max-time $(or $2,$1)'
else
- AC_PATH_PROG([FETCH], [fetch], [:])
- DOWNLOAD=${FETCH}
- DOWNLOAD_TO_STDOUT="${FETCH} -o-"
- DOWNLOAD_TIMEOUT='--timeout=$(or $2,$1)'
+ AC_PATH_PROG([FETCH], [fetch], :)
+ if test "${FETCH}" != ":" ; then
+ DOWNLOAD=${FETCH}
+ DOWNLOAD_TO_STDOUT="${FETCH} -o-"
+ DOWNLOAD_TIMEOUT='--timeout=$(or $2,$1)'
+ fi
fi
fi
-
AC_SUBST(DOWNLOAD)
AC_SUBST(DOWNLOAD_TO_STDOUT)
AC_SUBST(DOWNLOAD_TIMEOUT)
@@ -638,20 +647,23 @@ AC_SUBST(EDITLINE_LIB)
# * -le2fs-uuid on OpenBSD
# * in libsystem on OS X
AST_EXT_LIB_CHECK([LIBUUID], [uuid], [uuid_generate_random], [uuid/uuid.h], [])
-AST_EXT_LIB_CHECK([E2FSUUID], [e2fs-uuid], [uuid_generate_random], [uuid/uuid.h], [])
-AC_CHECK_FUNCS([uuid_generate_random], [SYSUUID=true], [SYSUUID=""])
-
if test "x$LIBUUID_LIB" != "x" ; then
UUID_INCLUDE="$LIBUUID_INCLUDE"
UUID_LIB="$LIBUUID_LIB"
-elif test "x$E2FSUUID_LIB" != "x" ; then
- UUID_INCLUDE="$E2FSUUID_INCLUDE"
- UUID_LIB="$E2FSUUID_LIB"
-elif test "x$SYSUUID" != "x" ; then
- UUID_INCLUDE=""
- UUID_LIB=""
else
- AC_MSG_ERROR([*** uuid support not found (this typically means the uuid development package is missing)])
+ AST_EXT_LIB_CHECK([E2FSUUID], [e2fs-uuid], [uuid_generate_random], [uuid/uuid.h], [])
+ if test "x$E2FSUUID_LIB" != "x" ; then
+ UUID_INCLUDE="$E2FSUUID_INCLUDE"
+ UUID_LIB="$E2FSUUID_LIB"
+ else
+ AC_CHECK_FUNCS([uuid_generate_random], [SYSUUID=true], [SYSUUID=""])
+ if test "x$SYSUUID" != "x" ; then
+ UUID_INCLUDE=""
+ UUID_LIB=""
+ else
+ AC_MSG_ERROR([*** uuid support not found (this typically means the uuid development package is missing)])
+ fi
+ fi
fi
AC_SUBST(UUID_INCLUDE)
AC_SUBST(UUID_LIB)
@@ -1313,6 +1325,9 @@ AC_ARG_ENABLE(rpath,
AC_MSG_CHECKING(whether to use rpath)
AST_RPATH=
+if test "${OSARCH}" = "NetBSD"; then
+ AST_RPATH="-Wl,-rpath,/usr/pkg/lib"
+fi
if test "${check_rpath}" != yes; then
AC_MSG_RESULT(skipped)
elif test "${prefix}" = /usr || test "${prefix}" = NONE; then
@@ -1449,6 +1464,23 @@ AC_LINK_IFELSE(
)
LIBS=${old_LIBS}
+# re-check without -ldl
+# Non-Linux platforms like FreeBSD and NetBSD do not need a library libdl.so.
+if test "${PBX_DLADDR}" = "0"; then
+ AC_MSG_CHECKING(for dladdr in dlfcn.h without -ldl)
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#define _GNU_SOURCE 1
+#include <dlfcn.h>],
+ [dladdr((void *)0, (void *)0)]
+ )],
+ AC_MSG_RESULT(yes)
+ PBX_DLADDR=1
+ AC_SUBST([PBX_DLADDR])
+ AC_DEFINE([HAVE_DLADDR], 1, [Define to 1 if your system has the dladdr() GNU extension]),
+ AC_MSG_RESULT(no)
+ )
+fi
+
# PKGCONFIG is used in later tests
PKG_PROG_PKG_CONFIG()
@@ -1853,7 +1885,7 @@ if test "${USE_IMAP_TK}" != "no"; then
CPPFLAGS="${saved_cppflags}"
LIBS="${saved_libs}"
imap_ldflags=""
- imap_libs="-lc-client"
+ imap_libs="-lcrypto -lssl -lc-client"
imap_include="-DUSE_SYSTEM_IMAP" #Try the imap directory first
CPPFLAGS="${CPPFLAGS} ${imap_include}"
LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
@@ -2286,6 +2318,7 @@ AST_PKG_CONFIG_CHECK([PYTHONDEV], [python])
AST_EXT_LIB_CHECK([POPT], [popt], [poptStrerror], [popt.h])
+AST_PKG_CONFIG_CHECK([PORTAUDIO], [portaudio-2.0])
AST_EXT_LIB_CHECK([PORTAUDIO], [portaudio], [Pa_GetDeviceCount], [portaudio.h])
AST_EXT_LIB_CHECK([PRI], [pri], [pri_connected_line_update], [libpri.h])
@@ -2555,12 +2588,7 @@ fi
AST_EXT_LIB_CHECK([TONEZONE], [tonezone], [tone_zone_find], [dahdi/tonezone.h], [${tonezone_extra} ${DAHDI_INCLUDE}])
-if test "${OSARCH}" = "OpenBSD";
-then
- AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -lvorbisfile -logg])
-else
- AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -lvorbisfile])
-fi
+AST_EXT_LIB_CHECK([VORBIS], [vorbis], [vorbis_info_init], [vorbis/codec.h], [-lm -lvorbisenc -lvorbisfile])
AST_C_DECLARE_CHECK([VORBIS_OPEN_CALLBACKS], [OV_CALLBACKS_NOCLOSE], [vorbis/vorbisfile.h])
AC_LANG_PUSH(C++)
diff --git a/contrib/scripts/install_prereq b/contrib/scripts/install_prereq
index 23a247a13..e588d5cd1 100755
--- a/contrib/scripts/install_prereq
+++ b/contrib/scripts/install_prereq
@@ -51,6 +51,54 @@ PACKAGES_RH="$PACKAGES_RH wget subversion"
PACKAGES_RH="$PACKAGES_RH bzip2 patch python-devel"
# Basic build system:
+PACKAGES_SUSE="make gcc gcc-c++ pkg-config"
+# Asterisk: basic requirements:
+PACKAGES_SUSE="$PACKAGES_SUSE libedit-devel libjansson-devel libuuid-devel sqlite3-devel libxml2-devel"
+# Asterisk: for addons:
+PACKAGES_SUSE="$PACKAGES_SUSE speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-devel portaudio-devel libcurl-devel xmlstarlet bison flex"
+PACKAGES_SUSE="$PACKAGES_SUSE postgresql-devel unixODBC-devel libtool libneon-devel gmime-devel lua-devel liburiparser-devel libxslt-devel libopenssl-devel"
+PACKAGES_SUSE="$PACKAGES_SUSE libmysqlclient-devel bluez-devel freeradius-client-devel freetds-devel bash"
+PACKAGES_SUSE="$PACKAGES_SUSE net-snmp-devel iksemel-devel libcorosync-devel newt-devel popt-devel libical-devel spandsp-devel"
+PACKAGES_SUSE="$PACKAGES_SUSE imap-devel libsrtp2-devel libgsm-devel doxygen graphviz zlib-devel openldap2-devel"
+PACKAGES_SUSE="$PACKAGES_SUSE codec2-devel fftw3-devel libsndfile-devel unbound-devel"
+# Asterisk: for the unpackaged below:
+PACKAGES_SUSE="$PACKAGES_SUSE wget subversion"
+# Asterisk: for ./configure --with-pjproject-bundled:
+PACKAGES_SUSE="$PACKAGES_SUSE bzip2 patch python-devel"
+
+# Basic build system:
+PACKAGES_ARCH="make gcc pkg-config"
+# Asterisk: basic requirements:
+PACKAGES_ARCH="$PACKAGES_ARCH libedit jansson libutil-linux libxml2 sqlite"
+# Asterisk: for addons:
+PACKAGES_ARCH="$PACKAGES_ARCH speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex"
+PACKAGES_ARCH="$PACKAGES_ARCH postgresql-libs unixodbc libtool neon gmime lua uriparser libxslt openssl"
+PACKAGES_ARCH="$PACKAGES_ARCH libmariadbclient bluez-libs radcli freetds bash"
+PACKAGES_ARCH="$PACKAGES_ARCH net-snmp libnewt popt libical spandsp"
+PACKAGES_ARCH="$PACKAGES_ARCH c-client binutils libsrtp gsm doxygen graphviz zlib libldap"
+PACKAGES_ARCH="$PACKAGES_ARCH fftw libsndfile unbound"
+# Asterisk: for the unpackaged below:
+PACKAGES_ARCH="$PACKAGES_ARCH wget subversion"
+# Asterisk: for ./configure --with-pjproject-bundled:
+PACKAGES_ARCH="$PACKAGES_ARCH bzip2 patch python2"
+
+# Basic build system:
+PACKAGES_NBSD="gmake pkg-config"
+# Asterisk: basic requirements:
+PACKAGES_NBSD="$PACKAGES_NBSD editline jansson sqlite3 libuuid libxml2"
+# Asterisk: for addons:
+PACKAGES_NBSD="$PACKAGES_NBSD speex speexdsp libogg libvorbis alsa-lib portaudio-devel curl bison flex"
+PACKAGES_NBSD="$PACKAGES_NBSD postgresql10-client unixodbc libltdl neon gmime lua52 uriparser libxslt openssl"
+PACKAGES_NBSD="$PACKAGES_NBSD mysql-client radiusclient-ng freetds bash"
+PACKAGES_NBSD="$PACKAGES_NBSD net-snmp iksemel popt libical spandsp"
+PACKAGES_NBSD="$PACKAGES_NBSD imap-uw srtp gsm doxygen graphviz libzip openldap-client"
+PACKAGES_NBSD="$PACKAGES_NBSD codec2 fftw libsndfile unbound"
+# Asterisk: for the unpackaged below:
+PACKAGES_NBSD="$PACKAGES_NBSD wget subversion-base"
+# Asterisk: for ./configure --with-pjproject-bundled:
+PACKAGES_NBSD="$PACKAGES_NBSD bzip2 patch python27"
+
+# Basic build system:
PACKAGES_OBSD="gmake"
# Asterisk: basic requirements:
PACKAGES_OBSD="$PACKAGES_OBSD libxml sqlite3 e2fsprogs jansson"
@@ -76,6 +124,7 @@ PACKAGES_FBSD="$PACKAGES_FBSD postgresql10-client unixODBC libltdl neon gmime26
PACKAGES_FBSD="$PACKAGES_FBSD mysql57-client radcli freetds"
PACKAGES_FBSD="$PACKAGES_FBSD net-snmp iksemel corosync newt popt libical spandsp"
PACKAGES_FBSD="$PACKAGES_FBSD cclient libbfd libsrtp gsm libilbc doxygen graphviz libzip openldap-client libhoard"
+PACKAGES_FBSD="$PACKAGES_FBSD codec2 fftw3 libsndfile unbound"
# Asterisk: for the unpackaged below:
PACKAGES_FBSD="$PACKAGES_FBSD wget subversion"
# Asterisk: for ./configure --with-pjproject-bundled:
@@ -130,6 +179,15 @@ check_installed_rpms() {
done
}
+check_installed_pacman() {
+ for pack in "$@"
+ do
+ if ! pacman -Q --explicit $pack >/dev/null 2>/dev/null
+ then echo $pack
+ fi
+ done
+}
+
check_installed_pkgs() {
for pack in "$@"
do
@@ -148,6 +206,15 @@ check_installed_fpkgs() {
done
}
+check_installed_zypper() {
+ for pack in "$@"
+ do
+ if ! zypper se -ixnC $pack >/dev/null 2>/dev/null
+ then echo $pack
+ fi
+ done
+}
+
handle_debian() {
if ! [ -x "$(command -v aptitude)" ]; then
apt-get install aptitude
@@ -166,6 +233,24 @@ handle_rh() {
fi
}
+handle_arch() {
+ extra_packs=`check_installed_pacman $PACKAGES_ARCH`
+ if [ x"$extra_packs" != "x" ] ; then
+ $testcmd pacman -S --asexplicit --noconfirm $extra_packs
+ fi
+}
+
+handle_nbsd() {
+ extra_packs=`check_installed_pkgs $PACKAGES_NBSD`
+ if [ x"$extra_packs" != "x" ] ; then
+ if [ -z "$PKG_PATH" ] ; then
+ # see NetBSD Problem Report #48177
+ export PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages/$(uname -s)/$(uname -p)/$(uname -r)/All"
+ fi
+ $testcmd pkg_add $extra_packs
+ fi
+}
+
handle_obsd() {
extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
if [ x"$extra_packs" != "x" ] ; then
@@ -180,6 +265,13 @@ handle_fbsd() {
fi
}
+handle_SUSE() {
+ extra_packs=`check_installed_zypper $PACKAGES_SUSE`
+ if [ x"$extra_packs" != "x" ] ; then
+ $testcmd zypper install --no-confirm $extra_packs
+ fi
+}
+
install_unpackaged() {
echo "*** Installing NBS (Network Broadcast Sound) ***"
svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk
@@ -243,7 +335,7 @@ OS=`uname -s`
unsupported_distro=''
# A number of distributions we don't (yet?) support.
-if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' -a "$OS" != 'FreeBSD' ]; then
+if [ "$OS" != 'Linux' -a "$OS" != 'NetBSD' -a "$OS" != 'OpenBSD' -a "$OS" != 'FreeBSD' ]; then
echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
exit 1
fi
@@ -256,10 +348,6 @@ if [ -f /etc/mandrake-release ]; then
unsupported_distro='Mandriva'
fi
-if [ -f /etc/SuSE-release ]; then
- unsupported_distro='SUSE'
-fi
-
if [ -f /etc/slackware-version ]; then
unsupported_distro='Slackware'
fi
@@ -274,6 +362,16 @@ if [ -r /etc/debian_version ]; then
handle_debian
elif [ -r /etc/redhat-release ]; then
handle_rh
+elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then
+ handle_SUSE
+elif [ -f /etc/os-release ] && . /etc/os-release && [ "$ID" = "opensuse" ]; then
+ handle_SUSE
+elif [ -r /etc/arch-release ]; then
+ handle_arch
+elif [ -f /etc/os-release ] && . /etc/os-release && [ "$ID_LIKE" = "archlinux" ]; then
+ handle_arch # $ID=arch
+elif [ "$OS" = 'NetBSD' ]; then
+ handle_nbsd
elif [ "$OS" = 'OpenBSD' ]; then
handle_obsd
elif [ "$OS" = 'FreeBSD' ]; then
diff --git a/include/asterisk.h b/include/asterisk.h
index 371860278..27d66b776 100644
--- a/include/asterisk.h
+++ b/include/asterisk.h
@@ -21,7 +21,7 @@
#include "asterisk/autoconfig.h"
#include "asterisk/compat.h"
-#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2) && defined(MALLOC_DEBUG)
+#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2)
#include "asterisk/astmm.h"
#endif
diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h
index 06300c861..4e4a65b31 100644
--- a/include/asterisk/astmm.h
+++ b/include/asterisk/astmm.h
@@ -32,27 +32,30 @@ extern "C" {
#define _ASTERISK_ASTMM_H
/* IWYU pragma: private, include "asterisk.h" */
+#if defined(MALLOC_DEBUG)
#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_realloc(void *ptr, size_t size);
void ast_std_free(void *ptr);
void ast_free_ptr(void *ptr);
-void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
-void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
-void *__ast_malloc(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);
+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_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);
-char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
-int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
+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);
+int __ast_repl_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)
+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)));
-void __ast_mm_init_phase_1(void);
-void __ast_mm_init_phase_2(void);
/*!
* \brief ASTMM_LIBC can be defined to control the meaning of standard allocators.
@@ -120,42 +123,42 @@ void __ast_mm_init_phase_2(void);
#if ASTMM_LIBC == ASTMM_REDIRECT
/* Redefine libc functions to our own versions */
-#define calloc(a,b) \
- __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define calloc(a, b) \
+ __ast_repl_calloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define malloc(a) \
- __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_repl_malloc(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define free(a) \
- __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define realloc(a,b) \
- __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define realloc(a, b) \
+ __ast_repl_realloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define strdup(a) \
- __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define strndup(a,b) \
- __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __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_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
-#define vasprintf(a,b,c) \
- __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __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__)
#elif ASTMM_LIBC == ASTMM_BLOCK
/* Redefine libc functions to cause compile errors */
-#define calloc(a,b) \
- Do_not_use_calloc__use_ast_calloc->fail(a,b)
+#define calloc(a, b) \
+ Do_not_use_calloc__use_ast_calloc->fail(a, b)
#define malloc(a) \
Do_not_use_malloc__use_ast_malloc->fail(a)
#define free(a) \
Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a)
-#define realloc(a,b) \
- Do_not_use_realloc__use_ast_realloc->fail(a,b)
+#define realloc(a, b) \
+ Do_not_use_realloc__use_ast_realloc->fail(a, b)
#define strdup(a) \
Do_not_use_strdup__use_ast_strdup->fail(a)
-#define strndup(a,b) \
- Do_not_use_strndup__use_ast_strndup->fail(a,b)
+#define strndup(a, b) \
+ Do_not_use_strndup__use_ast_strndup->fail(a, b)
#define asprintf(a, b, c...) \
- Do_not_use_asprintf__use_ast_asprintf->fail(a,b,c)
-#define vasprintf(a,b,c) \
- Do_not_use_vasprintf__use_ast_vasprintf->fail(a,b,c)
+ Do_not_use_asprintf__use_ast_asprintf->fail(a, b, c)
+#define vasprintf(a, b, c) \
+ Do_not_use_vasprintf__use_ast_vasprintf->fail(a, b, c)
#else
#error "Unacceptable value for the macro ASTMM_LIBC"
@@ -166,7 +169,7 @@ void __ast_mm_init_phase_2(void);
/* Provide our own definition for ast_free */
#define ast_free(a) \
- __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
#error "NEVER INCLUDE astmm.h DIRECTLY!!"
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 06114616d..6d747ae5a 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -663,7 +663,7 @@
/* Define to 1 if you have the popt library. */
#undef HAVE_POPT
-/* Define to 1 if you have the PortAudio library. */
+/* Define if your system has the PORTAUDIO libraries. */
#undef HAVE_PORTAUDIO
/* Define to 1 if you have the `pow' function. */
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 3dfbe61d9..8cb03800e 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -1149,7 +1149,7 @@ enum ama_flags {
* \deprecated You should use the ast_datastore_alloc() generic function instead.
* \version 1.6.1 deprecated
*/
-struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
+struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
__attribute__((deprecated));
/*!
@@ -1208,7 +1208,7 @@ struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const
* and "default" context.
* \note Since 12.0.0 this function returns with the newly created channel locked.
*/
-struct ast_channel * attribute_malloc __attribute__((format(printf, 15, 16)))
+struct ast_channel * __attribute__((format(printf, 15, 16)))
__ast_channel_alloc(int needqueue, int state, const char *cid_num,
const char *cid_name, const char *acctcode,
const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
diff --git a/include/asterisk/chanvars.h b/include/asterisk/chanvars.h
index 2040c7b65..1a303c5f7 100644
--- a/include/asterisk/chanvars.h
+++ b/include/asterisk/chanvars.h
@@ -35,12 +35,10 @@ AST_LIST_HEAD_NOLOCK(varshead, ast_var_t);
struct varshead *ast_var_list_create(void);
void ast_var_list_destroy(struct varshead *head);
-#ifdef __AST_DEBUG_MALLOC
+
struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function);
-#define ast_var_assign(a,b) _ast_var_assign(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-struct ast_var_t *ast_var_assign(const char *name, const char *value);
-#endif
+#define ast_var_assign(name, value) _ast_var_assign(name, value, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
void ast_var_delete(struct ast_var_t *var);
const char *ast_var_name(const struct ast_var_t *var);
const char *ast_var_full_name(const struct ast_var_t *var);
diff --git a/include/asterisk/compat.h b/include/asterisk/compat.h
index 2e89a39eb..85472837c 100644
--- a/include/asterisk/compat.h
+++ b/include/asterisk/compat.h
@@ -64,7 +64,7 @@
void closefrom(int lowfd);
#endif
-#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_ASPRINTF)
int __attribute__((format(printf, 2, 3))) asprintf(char **str, const char *fmt, ...);
#endif
@@ -96,7 +96,7 @@ int setenv(const char *name, const char *value, int overwrite);
char *strcasestr(const char *, const char *);
#endif
-#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_STRNDUP)
char *strndup(const char *, size_t);
#endif
@@ -116,7 +116,7 @@ uint64_t strtoq(const char *nptr, char **endptr, int base);
int unsetenv(const char *name);
#endif
-#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_VASPRINTF)
int __attribute__((format(printf, 2, 0))) vasprintf(char **strp, const char *fmt, va_list ap);
#endif
diff --git a/include/asterisk/config.h b/include/asterisk/config.h
index a7b144e27..c1b7dea8d 100644
--- a/include/asterisk/config.h
+++ b/include/asterisk/config.h
@@ -910,12 +910,9 @@ void ast_category_destroy(struct ast_category *cat);
struct ast_variable *ast_category_detach_variables(struct ast_category *cat);
void ast_category_rename(struct ast_category *cat, const char *name);
-#ifdef __AST_DEBUG_MALLOC
struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *function, int lineno);
#define ast_variable_new(name, value, filename) _ast_variable_new(name, value, filename, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#else
-struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename);
-#endif
+
struct ast_config_include *ast_include_new(struct ast_config *conf, const char *from_file, const char *included_file, int is_exec, const char *exec_file, int from_lineno, char *real_included_file_name, int real_included_file_name_size);
struct ast_config_include *ast_include_find(struct ast_config *conf, const char *included_file);
void ast_include_rename(struct ast_config *conf, const char *from_file, const char *to_file);
diff --git a/include/asterisk/datastore.h b/include/asterisk/datastore.h
index 8d6516bc1..7a7d99be6 100644
--- a/include/asterisk/datastore.h
+++ b/include/asterisk/datastore.h
@@ -82,7 +82,7 @@ struct ast_datastore {
* \param file, line, function
* \version 1.6.1 moved here and renamed from ast_channel_datastore_alloc
*/
-struct ast_datastore * attribute_malloc __ast_datastore_alloc(
+struct ast_datastore *__ast_datastore_alloc(
const struct ast_datastore_info *info, const char *uid, struct ast_module *mod,
const char *file, int line, const char *function);
diff --git a/include/asterisk/hashtab.h b/include/asterisk/hashtab.h
index cfe035b28..64ed1bf6f 100644
--- a/include/asterisk/hashtab.h
+++ b/include/asterisk/hashtab.h
@@ -251,22 +251,15 @@ unsigned int ast_hashtab_hash_short(const short num);
* \param hash a func ptr to do the hashing
* \param do_locking use locks to guarantee safety of iterators/insertion/deletion -- real simpleminded right now
*/
-#ifdef __AST_DEBUG_MALLOC
-struct ast_hashtab * _ast_hashtab_create(int initial_buckets,
- int (*compare)(const void *a, const void *b),
- int (*resize)(struct ast_hashtab *),
- int (*newsize)(struct ast_hashtab *tab),
- unsigned int (*hash)(const void *obj),
- int do_locking, const char *file, int lineno, const char *function);
-#define ast_hashtab_create(a,b,c,d,e,f) _ast_hashtab_create(a,b,c,d,e,f,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-struct ast_hashtab * ast_hashtab_create(int initial_buckets,
- int (*compare)(const void *a, const void *b),
- int (*resize)(struct ast_hashtab *),
- int (*newsize)(struct ast_hashtab *tab),
- unsigned int (*hash)(const void *obj),
- int do_locking );
-#endif
+struct ast_hashtab *_ast_hashtab_create(int initial_buckets,
+ int (*compare)(const void *a, const void *b),
+ int (*resize)(struct ast_hashtab *),
+ int (*newsize)(struct ast_hashtab *tab),
+ unsigned int (*hash)(const void *obj),
+ int do_locking,
+ const char *file, int lineno, const char *function);
+#define ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking) \
+ _ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief This func will free the hash table and all its memory.
@@ -294,12 +287,9 @@ void ast_hashtab_destroy( struct ast_hashtab *tab, void (*objdestroyfunc)(void *
* \retval 1 on success
* \retval 0 if there's a problem
*/
-#ifdef __AST_DEBUG_MALLOC
int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
-#define ast_hashtab_insert_immediate(a,b) _ast_hashtab_insert_immediate(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#else
-int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj);
-#endif
+#define ast_hashtab_insert_immediate(tab, obj) \
+ _ast_hashtab_insert_immediate(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Insert without checking, hashing or locking
@@ -311,12 +301,9 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj);
* \retval 1 on success
* \retval 0 if there's a problem
*/
-#ifdef __AST_DEBUG_MALLOC
int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func);
-#define ast_hashtab_insert_immediate_bucket(a,b,c) _ast_hashtab_insert_immediate_bucket(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#else
-int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h);
-#endif
+#define ast_hashtab_insert_immediate_bucket(tab, obj, h) \
+ _ast_hashtab_insert_immediate_bucket(tab, obj, h, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Check and insert new object only if it is not there.
@@ -324,12 +311,9 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj
* \retval 1 on success
* \retval 0 if there's a problem, or it's already there.
*/
-#ifdef __AST_DEBUG_MALLOC
int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
-#define ast_hashtab_insert_safe(a,b) _ast_hashtab_insert_safe(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
-#else
-int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj);
-#endif
+#define ast_hashtab_insert_safe(tab, obj) \
+ _ast_hashtab_insert_safe(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Lookup this object in the hash table.
@@ -362,20 +346,14 @@ int ast_hashtab_size( struct ast_hashtab *tab);
int ast_hashtab_capacity( struct ast_hashtab *tab);
/*! \brief Return a copy of the hash table */
-#ifdef __AST_DEBUG_MALLOC
struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func);
-#define ast_hashtab_dup(a,b) _ast_hashtab_dup(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj));
-#endif
+#define ast_hashtab_dup(tab, obj_dup_func) \
+ _ast_hashtab_dup(tab, obj_dup_func, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*! \brief Gives an iterator to hastable */
-#ifdef __AST_DEBUG_MALLOC
struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
-#define ast_hashtab_start_traversal(a) _ast_hashtab_start_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab);
-#endif
+#define ast_hashtab_start_traversal(tab) \
+ _ast_hashtab_start_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*! \brief end the traversal, free the iterator, unlock if necc. */
void ast_hashtab_end_traversal(struct ast_hashtab_iter *it);
@@ -395,12 +373,9 @@ void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj);
/* ------------------ */
/*! \brief Gives an iterator to hastable */
-#ifdef __AST_DEBUG_MALLOC
struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
-#define ast_hashtab_start_write_traversal(a) _ast_hashtab_start_write_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab);
-#endif
+#define ast_hashtab_start_write_traversal(tab) \
+ _ast_hashtab_start_write_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*! \brief Looks up the object, removes the corresponding bucket */
void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void *obj);
diff --git a/include/asterisk/heap.h b/include/asterisk/heap.h
index 728327936..83c69a8d6 100644
--- a/include/asterisk/heap.h
+++ b/include/asterisk/heap.h
@@ -97,14 +97,10 @@ typedef int (*ast_heap_cmp_fn)(void *elm1, void *elm2);
* \return An instance of a max heap
* \since 1.6.1
*/
-#ifdef __AST_DEBUG_MALLOC
struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
ssize_t index_offset, const char *file, int lineno, const char *func);
-#define ast_heap_create(a,b,c) _ast_heap_create(a,b,c,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
- ssize_t index_offset);
-#endif
+#define ast_heap_create(init_height, cmp_fn, index_offset) \
+ _ast_heap_create(init_height, cmp_fn, index_offset, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Destroy a max heap
@@ -126,12 +122,9 @@ struct ast_heap *ast_heap_destroy(struct ast_heap *h);
* \retval non-zero failure
* \since 1.6.1
*/
-#ifdef __AST_DEBUG_MALLOC
int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func);
-#define ast_heap_push(a,b) _ast_heap_push(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-int ast_heap_push(struct ast_heap *h, void *elm);
-#endif
+#define ast_heap_push(h, elm) \
+ _ast_heap_push(h, elm, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Pop the max element off of the heap
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index 69f2fcca4..e1ff2fc1d 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -228,11 +228,11 @@ struct ast_string_field_mgr {
ast_string_field last_alloc; /*!< the last field allocated */
struct ast_string_field_pool *embedded_pool; /*!< pointer to the embedded pool, if any */
struct ast_string_field_vector string_fields; /*!< field vector for compare and copy */
-#if defined(__AST_DEBUG_MALLOC)
+ /* v-- MALLOC_DEBUG information */
const char *owner_file; /*!< filename of owner */
const char *owner_func; /*!< function name of owner */
int owner_line; /*!< line number of owner */
-#endif
+ /* ^-- MALLOC_DEBUG information */
};
/*!
@@ -434,7 +434,7 @@ int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_
* \internal
* \brief internal version of ast_calloc_with_stringfields
*/
-void * attribute_malloc __ast_calloc_with_stringfields(unsigned int num_structs,
+void *__ast_calloc_with_stringfields(unsigned int num_structs,
size_t struct_size, size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size,
const char *file, int lineno, const char *func);
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index 85393b4f9..e4bef5f0f 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -617,8 +617,8 @@ int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str *
* \note The result of this function is dynamically allocated memory, and must
* be free()'d after it is no longer needed.
*/
-#ifdef __AST_DEBUG_MALLOC
-#define ast_str_create(a) _ast_str_create(a,__FILE__,__LINE__,__PRETTY_FUNCTION__)
+#define ast_str_create(init_len) \
+ _ast_str_create(init_len, __FILE__, __LINE__, __PRETTY_FUNCTION__)
AST_INLINE_API(
struct ast_str * attribute_malloc _ast_str_create(size_t init_len,
const char *file, int lineno, const char *func),
@@ -636,24 +636,6 @@ struct ast_str * attribute_malloc _ast_str_create(size_t init_len,
return buf;
}
)
-#else
-AST_INLINE_API(
-struct ast_str * attribute_malloc ast_str_create(size_t init_len),
-{
- struct ast_str *buf;
-
- buf = (struct ast_str *)ast_calloc(1, sizeof(*buf) + init_len);
- if (buf == NULL)
- return NULL;
-
- buf->__AST_STR_LEN = init_len;
- buf->__AST_STR_USED = 0;
- buf->__AST_STR_TS = DS_MALLOC;
-
- return buf;
-}
-)
-#endif
/*! \brief Reset the content of a dynamic string.
* Useful before a series of ast_str_append.
@@ -772,7 +754,6 @@ char *ast_str_truncate(struct ast_str *buf, ssize_t len),
/*!
* Make space in a new string (e.g. to read in data from a file)
*/
-#ifdef __AST_DEBUG_MALLOC
AST_INLINE_API(
int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function),
{
@@ -796,32 +777,8 @@ int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file,
return 0;
}
)
-#define ast_str_make_space(a,b) _ast_str_make_space(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-AST_INLINE_API(
-int ast_str_make_space(struct ast_str **buf, size_t new_len),
-{
- struct ast_str *old_buf = *buf;
-
- if (new_len <= (*buf)->__AST_STR_LEN)
- return 0; /* success */
- if ((*buf)->__AST_STR_TS == DS_ALLOCA || (*buf)->__AST_STR_TS == DS_STATIC)
- return -1; /* cannot extend */
- *buf = (struct ast_str *)ast_realloc(*buf, new_len + sizeof(struct ast_str));
- if (*buf == NULL) {
- *buf = old_buf;
- return -1;
- }
- if ((*buf)->__AST_STR_TS != DS_MALLOC) {
- pthread_setspecific((*buf)->__AST_STR_TS->key, *buf);
- _DB1(__ast_threadstorage_object_replace(old_buf, *buf, new_len + sizeof(struct ast_str));)
- }
-
- (*buf)->__AST_STR_LEN = new_len;
- return 0;
-}
-)
-#endif
+#define ast_str_make_space(buf, new_len) \
+ _ast_str_make_space(buf, new_len, __FILE__, __LINE__, __PRETTY_FUNCTION__)
AST_INLINE_API(
int ast_str_copy_string(struct ast_str **dst, struct ast_str *src),
@@ -965,14 +922,12 @@ enum {
* through calling one of the other functions or macros defined in this
* file.
*/
-#ifdef __AST_DEBUG_MALLOC
-int __attribute__((format(printf, 4, 0))) __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len,
- int append, const char *fmt, va_list ap, const char *file, int lineno, const char *func);
-#define __ast_str_helper(a,b,c,d,e) __ast_debug_str_helper(a,b,c,d,e,__FILE__,__LINE__,__PRETTY_FUNCTION__)
-#else
-int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf, ssize_t max_len,
- int append, const char *fmt, va_list ap);
-#endif
+int __attribute__((format(printf, 4, 0))) __ast_str_helper(struct ast_str **buf,
+ ssize_t max_len, int append, const char *fmt, va_list ap,
+ const char *file, int lineno, const char *func);
+#define _ast_str_helper(buf, max_len, append, fmt, ap) \
+ __ast_str_helper(buf, max_len, append, fmt, ap, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
char *__ast_str_helper2(struct ast_str **buf, ssize_t max_len,
const char *src, size_t maxsrc, int append, int escapecommas);
@@ -1022,7 +977,7 @@ char *__ast_str_helper2(struct ast_str **buf, ssize_t max_len,
*/
AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap),
{
- return __ast_str_helper(buf, max_len, 0, fmt, ap);
+ return _ast_str_helper(buf, max_len, 0, fmt, ap);
}
)
@@ -1040,7 +995,7 @@ AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_set_va(struct a
*/
AST_INLINE_API(int __attribute__((format(printf, 3, 0))) ast_str_append_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap),
{
- return __ast_str_helper(buf, max_len, 1, fmt, ap);
+ return _ast_str_helper(buf, max_len, 1, fmt, ap);
}
)
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index c6c34074e..bb9aa2a3c 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -509,11 +509,11 @@ long int ast_random(void);
#endif
-#ifndef __AST_DEBUG_MALLOC
-#define ast_std_malloc malloc
-#define ast_std_calloc calloc
-#define ast_std_realloc realloc
-#define ast_std_free free
+#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
@@ -521,8 +521,44 @@ long int ast_random(void);
* 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_free_ptr ast_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 \
@@ -539,7 +575,8 @@ void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, c
DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
- if (!(p = malloc(len))) {
+ p = __ast_repl_malloc(len, file, lineno, func);
+ if (!p) {
MALLOC_FAILURE_MSG;
}
@@ -554,7 +591,24 @@ void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, i
DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
- if (!(p = calloc(num, len))) {
+ 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;
}
@@ -563,13 +617,14 @@ void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, i
)
AST_INLINE_API(
-void * attribute_malloc __ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
+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);
- if (!(newp = realloc(p, len))) {
+ newp = __ast_repl_realloc(p, len, file, lineno, func);
+ if (!newp) {
MALLOC_FAILURE_MSG;
}
@@ -585,7 +640,8 @@ char * attribute_malloc __ast_strdup(const char *str, const char *file, int line
DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
if (str) {
- if (!(newstr = strdup(str))) {
+ newstr = __ast_repl_strdup(str, file, lineno, func);
+ if (!newstr) {
MALLOC_FAILURE_MSG;
}
}
@@ -602,7 +658,8 @@ char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *f
DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
if (str) {
- if (!(newstr = strndup(str, len))) {
+ newstr = __ast_repl_strndup(str, len, file, lineno, func);
+ if (!newstr) {
MALLOC_FAILURE_MSG;
}
}
@@ -611,8 +668,30 @@ char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *f
}
)
-int __attribute__((format(printf, 5, 6)))
- __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...);
+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)))
@@ -622,7 +701,7 @@ int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, i
DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1);
- res = vasprintf(ret, fmt, ap);
+ res = __ast_repl_vasprintf(ret, fmt, ap, file, lineno, func);
if (res < 0) {
/*
* *ret is undefined so set to NULL to ensure it is
@@ -636,8 +715,6 @@ int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, i
}
)
-#endif /* AST_DEBUG_MALLOC */
-
/*!
* \brief A wrapper for malloc()
*
@@ -671,7 +748,7 @@ int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, i
* The arguments and return value are the same as calloc()
*/
#define ast_calloc_cache(num, len) \
- __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_calloc_cache((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief A wrapper for realloc()
diff --git a/main/astmm.c b/main/astmm.c
index accd2ffcf..1fa35d728 100644
--- a/main/astmm.c
+++ b/main/astmm.c
@@ -149,31 +149,6 @@ AST_MUTEX_DEFINE_STATIC_NOTRACKING(reglock);
} \
} while (0)
-void *ast_std_malloc(size_t size)
-{
- return malloc(size);
-}
-
-void *ast_std_calloc(size_t nmemb, size_t size)
-{
- return calloc(nmemb, size);
-}
-
-void *ast_std_realloc(void *ptr, size_t size)
-{
- return realloc(ptr, size);
-}
-
-void ast_std_free(void *ptr)
-{
- free(ptr);
-}
-
-void ast_free_ptr(void *ptr)
-{
- ast_free(ptr);
-}
-
static void print_backtrace(struct ast_bt *bt)
{
int i = 0;
@@ -479,7 +454,7 @@ static void __ast_free_region(void *ptr, const char *file, int lineno, const cha
}
}
-void *__ast_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)
{
void *ptr;
@@ -491,7 +466,7 @@ void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, cons
return ptr;
}
-void *__ast_calloc_cache(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 *ptr;
@@ -503,7 +478,7 @@ void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno
return ptr;
}
-void *__ast_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)
{
void *ptr;
@@ -539,7 +514,7 @@ static struct ast_region *region_find(void *ptr)
return reg;
}
-void *__ast_realloc(void *ptr, size_t size, 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)
{
size_t len;
struct ast_region *found;
@@ -588,7 +563,7 @@ void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const
return new_mem;
}
-char *__ast_strdup(const char *s, const char *file, int lineno, const char *func)
+char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func)
{
size_t len;
void *ptr;
@@ -603,7 +578,7 @@ char *__ast_strdup(const char *s, const char *file, int lineno, const char *func
return ptr;
}
-char *__ast_strndup(const char *s, size_t n, 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)
{
size_t len;
char *ptr;
@@ -621,7 +596,7 @@ char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const
return ptr;
}
-int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *fmt, ...)
+int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *fmt, ...)
{
int size;
va_list ap, ap2;
@@ -642,7 +617,7 @@ int __ast_asprintf(const char *file, int lineno, const char *func, char **strp,
return size;
}
-int __ast_vasprintf(char **strp, const char *fmt, va_list ap, const char *file, int lineno, const char *func)
+int __ast_repl_vasprintf(char **strp, const char *fmt, va_list ap, const char *file, int lineno, const char *func)
{
int size;
va_list ap2;
@@ -1543,4 +1518,83 @@ void __ast_mm_init_phase_2(void)
ast_register_cleanup(mm_atexit_ast);
}
+#else /* !defined(__AST_DEBUG_MALLOC) */
+
+void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
+{
+ return calloc(nmemb, size);
+}
+
+void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
+{
+ return calloc(nmemb, size);
+}
+
+void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func)
+{
+ return malloc(size);
+}
+
+void __ast_free(void *ptr, const char *file, int lineno, const char *func)
+{
+ free(ptr);
+}
+
+void *__ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
+{
+ return realloc(ptr, size);
+}
+
+char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func)
+{
+ return strdup(s);
+}
+
+char *__ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func)
+{
+ return strndup(s, n);
+}
+
+int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
+{
+ va_list ap;
+ int rc = 0;
+
+ va_start(ap, format);
+ rc = vasprintf(strp, format, ap);
+ va_end(ap);
+
+ return rc;
+}
+
+int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
+{
+ return vasprintf(strp, format, ap);
+}
+
#endif /* defined(__AST_DEBUG_MALLOC) */
+
+void *ast_std_malloc(size_t size)
+{
+ return malloc(size);
+}
+
+void *ast_std_calloc(size_t nmemb, size_t size)
+{
+ return calloc(nmemb, size);
+}
+
+void *ast_std_realloc(void *ptr, size_t size)
+{
+ return realloc(ptr, size);
+}
+
+void ast_std_free(void *ptr)
+{
+ free(ptr);
+}
+
+void ast_free_ptr(void *ptr)
+{
+ ast_free(ptr);
+}
diff --git a/main/astobj2_container.c b/main/astobj2_container.c
index ae647d2dd..9bea58f74 100644
--- a/main/astobj2_container.c
+++ b/main/astobj2_container.c
@@ -935,12 +935,15 @@ void ao2_container_unregister(const char *name)
}
#if defined(AO2_DEBUG)
-static int ao2_complete_reg_cb(void *obj, void *arg, void *data, int flags)
+static int ao2_complete_reg_cb(void *obj, void *arg, int flags)
{
- struct ao2_reg_match *which = data;
+ struct ao2_reg_container *reg = obj;
- /* ao2_reg_sort_cb() has already filtered the search to matching keys */
- return (which->find_nth < ++which->count) ? (CMP_MATCH | CMP_STOP) : 0;
+ if (ast_cli_completion_add(ast_strdup(reg->name))) {
+ return CMP_STOP;
+ }
+
+ return 0;
}
#endif /* defined(AO2_DEBUG) */
@@ -948,9 +951,6 @@ static int ao2_complete_reg_cb(void *obj, void *arg, void *data, int flags)
static char *complete_container_names(struct ast_cli_args *a)
{
struct ao2_reg_partial_key partial_key;
- struct ao2_reg_match which;
- struct ao2_reg_container *reg;
- char *name;
if (a->pos != 3) {
return NULL;
@@ -958,17 +958,10 @@ static char *complete_container_names(struct ast_cli_args *a)
partial_key.len = strlen(a->word);
partial_key.name = a->word;
- which.find_nth = a->n;
- which.count = 0;
- reg = ao2_t_callback_data(reg_containers, partial_key.len ? OBJ_SEARCH_PARTIAL_KEY : 0,
- ao2_complete_reg_cb, &partial_key, &which, "Find partial registered container");
- if (reg) {
- name = ast_strdup(reg->name);
- ao2_t_ref(reg, -1, "Done with registered container object.");
- } else {
- name = NULL;
- }
- return name;
+ ao2_callback(reg_containers, partial_key.len ? OBJ_SEARCH_PARTIAL_KEY : 0,
+ ao2_complete_reg_cb, &partial_key);
+
+ return NULL;
}
#endif /* defined(AO2_DEBUG) */
diff --git a/main/ccss.c b/main/ccss.c
index 29780d875..9cf16e34d 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -4547,11 +4547,9 @@ static int kill_cores(void *obj, void *arg, int flags)
return 0;
}
-static char *complete_core_id(const char *line, const char *word, int pos, int state)
+static char *complete_core_id(const char *word)
{
- int which = 0;
int wordlen = strlen(word);
- char *ret = NULL;
struct ao2_iterator core_iter = ao2_iterator_init(cc_core_instances, 0);
struct cc_core_instance *core_instance;
@@ -4559,15 +4557,16 @@ static char *complete_core_id(const char *line, const char *word, int pos, int s
cc_unref(core_instance, "CLI tab completion iteration")) {
char core_id_str[20];
snprintf(core_id_str, sizeof(core_id_str), "%d", core_instance->core_id);
- if (!strncmp(word, core_id_str, wordlen) && ++which > state) {
- ret = ast_strdup(core_id_str);
- cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
- break;
+ if (!strncmp(word, core_id_str, wordlen)) {
+ if (ast_cli_completion_add(ast_strdup(core_id_str))) {
+ cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
+ break;
+ }
}
}
ao2_iterator_destroy(&core_iter);
- return ret;
+ return NULL;
}
static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -4583,7 +4582,7 @@ static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
return NULL;
case CLI_GENERATE:
if (a->pos == 3 && !strcasecmp(a->argv[2], "core")) {
- return complete_core_id(a->line, a->word, a->pos, a->n);
+ return complete_core_id(a->word);
}
return NULL;
}
diff --git a/main/cdr.c b/main/cdr.c
index 462e9c189..528673311 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -3951,18 +3951,14 @@ static char *handle_cli_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_a
/*! \brief Complete user input for 'cdr show' */
static char *cli_complete_show(struct ast_cli_args *a)
{
- char *result = NULL;
int wordlen = strlen(a->word);
- int which = 0;
struct ao2_iterator it_cdrs;
struct cdr_object *cdr;
it_cdrs = ao2_iterator_init(active_cdrs_master, 0);
while ((cdr = ao2_iterator_next(&it_cdrs))) {
- if (!strncasecmp(a->word, cdr->party_a.snapshot->name, wordlen) &&
- (++which > a->n)) {
- result = ast_strdup(cdr->party_a.snapshot->name);
- if (result) {
+ if (!strncasecmp(a->word, cdr->party_a.snapshot->name, wordlen)) {
+ if (ast_cli_completion_add(ast_strdup(cdr->party_a.snapshot->name))) {
ao2_ref(cdr, -1);
break;
}
@@ -3970,7 +3966,8 @@ static char *cli_complete_show(struct ast_cli_args *a)
ao2_ref(cdr, -1);
}
ao2_iterator_destroy(&it_cdrs);
- return result;
+
+ return NULL;
}
static void cli_show_channels(struct ast_cli_args *a)
diff --git a/main/channel.c b/main/channel.c
index ebd39c70b..c7847cbd4 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -304,25 +304,23 @@ static char *handle_cli_core_show_channeltypes(struct ast_cli_entry *e, int cmd,
static char *complete_channeltypes(struct ast_cli_args *a)
{
struct chanlist *cl;
- int which = 0;
int wordlen;
- char *ret = NULL;
- if (a->pos != 3)
+ if (a->pos != 3) {
return NULL;
+ }
wordlen = strlen(a->word);
AST_RWLIST_RDLOCK(&backends);
AST_RWLIST_TRAVERSE(&backends, cl, list) {
- if (!strncasecmp(a->word, cl->tech->type, wordlen) && ++which > a->n) {
- ret = ast_strdup(cl->tech->type);
- break;
+ if (!strncasecmp(a->word, cl->tech->type, wordlen)) {
+ ast_cli_completion_add(ast_strdup(cl->tech->type));
}
}
AST_RWLIST_UNLOCK(&backends);
- return ret;
+ return NULL;
}
/*! \brief Show details about a channel driver - CLI command */
@@ -782,7 +780,7 @@ static int does_id_conflict(const char *uniqueid)
}
/*! \brief Create a new channel structure */
-static struct ast_channel * attribute_malloc __attribute__((format(printf, 15, 0)))
+static struct ast_channel *__attribute__((format(printf, 15, 0)))
__ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char *cid_name,
const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids,
const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint,
diff --git a/main/chanvars.c b/main/chanvars.c
index 2cc90e43a..0802646b9 100644
--- a/main/chanvars.c
+++ b/main/chanvars.c
@@ -33,21 +33,15 @@
#include "asterisk/strings.h"
#include "asterisk/utils.h"
-#ifdef __AST_DEBUG_MALLOC
struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function)
-#else
-struct ast_var_t *ast_var_assign(const char *name, const char *value)
-#endif
{
struct ast_var_t *var;
int name_len = strlen(name) + 1;
int value_len = strlen(value) + 1;
-#ifdef __AST_DEBUG_MALLOC
- if (!(var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char), file, lineno, function))) {
-#else
- if (!(var = ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char)))) {
-#endif
+ var = __ast_calloc(sizeof(*var) + name_len + value_len, sizeof(char),
+ file, lineno, function);
+ if (!var) {
return NULL;
}
diff --git a/main/cli.c b/main/cli.c
index 80c184328..e46d3427c 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1655,8 +1655,15 @@ char *ast_cli_complete(const char *word, const char * const choices[], int state
len = ast_strlen_zero(word) ? 0 : strlen(word);
for (i = 0; choices[i]; i++) {
- if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state)
- return ast_strdup(choices[i]);
+ if ((!len || !strncasecmp(word, choices[i], len)) && ++which > state) {
+ if (state != -1) {
+ return ast_strdup(choices[i]);
+ }
+
+ if (ast_cli_completion_add(ast_strdup(choices[i]))) {
+ return NULL;
+ }
+ }
}
return NULL;
}
@@ -1682,9 +1689,16 @@ char *ast_complete_channels(const char *line, const char *word, int pos, int sta
struct ast_channel_snapshot *snapshot = stasis_message_data(msg);
if (!strncasecmp(word, snapshot->name, wordlen) && (++which > state)) {
- ret = ast_strdup(snapshot->name);
- ao2_ref(msg, -1);
- break;
+ if (state != -1) {
+ ret = ast_strdup(snapshot->name);
+ ao2_ref(msg, -1);
+ break;
+ }
+
+ if (ast_cli_completion_add(ast_strdup(snapshot->name))) {
+ ao2_ref(msg, -1);
+ break;
+ }
}
}
ao2_iterator_destroy(&iter);
diff --git a/main/config.c b/main/config.c
index 14908a50f..77bb83925 100644
--- a/main/config.c
+++ b/main/config.c
@@ -287,11 +287,7 @@ struct ast_config_include {
static void ast_variable_destroy(struct ast_variable *doomed);
static void ast_includes_destroy(struct ast_config_include *incls);
-#ifdef __AST_DEBUG_MALLOC
struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *func, int lineno)
-#else
-struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename)
-#endif
{
struct ast_variable *variable;
int name_len = strlen(name) + 1;
@@ -303,13 +299,9 @@ struct ast_variable *ast_variable_new(const char *name, const char *value, const
fn_len = MIN_VARIABLE_FNAME_SPACE;
}
- if (
-#ifdef __AST_DEBUG_MALLOC
- (variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable), file, lineno, func))
-#else
- (variable = ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable)))
-#endif
- ) {
+ variable = __ast_calloc(1, fn_len + name_len + val_len + sizeof(*variable),
+ file, lineno, func);
+ if (variable) {
char *dst = variable->stuff; /* writable space starts here */
/* Put file first so ast_include_rename() can calculate space available. */
diff --git a/main/datastore.c b/main/datastore.c
index a12bbdf34..5edad2413 100644
--- a/main/datastore.c
+++ b/main/datastore.c
@@ -47,7 +47,8 @@ struct ast_datastore *__ast_datastore_alloc(
return NULL;
}
- if (!(datastore = __ast_calloc(1, sizeof(*datastore), file, line, function))) {
+ datastore = __ast_calloc(1, sizeof(*datastore), file, line, function);
+ if (!datastore) {
return NULL;
}
diff --git a/main/hashtab.c b/main/hashtab.c
index eefe44304..1f9c7bfe8 100644
--- a/main/hashtab.c
+++ b/main/hashtab.c
@@ -41,12 +41,10 @@
#include "asterisk/hashtab.h"
-#ifdef __AST_DEBUG_MALLOC
static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
-#define ast_hashtab_resize(a) _ast_hashtab_resize(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
-#else
-static void ast_hashtab_resize(struct ast_hashtab *tab);
-#endif
+#define ast_hashtab_resize(tab) \
+ _ast_hashtab_resize(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
static void *ast_hashtab_lookup_internal(struct ast_hashtab *tab, const void *obj, unsigned int h);
/* some standard, default routines for general use */
@@ -215,40 +213,28 @@ unsigned int ast_hashtab_hash_short(const short x)
return x;
}
-struct ast_hashtab *
-#ifdef __AST_DEBUG_MALLOC
-_ast_hashtab_create
-#else
-ast_hashtab_create
-#endif
-(int initial_buckets,
+struct ast_hashtab *_ast_hashtab_create(int initial_buckets,
int (*compare)(const void *a, const void *b),
int (*resize)(struct ast_hashtab *),
int (*newsize)(struct ast_hashtab *tab),
unsigned int (*hash)(const void *obj),
- int do_locking
-#ifdef __AST_DEBUG_MALLOC
- , const char *file, int lineno, const char *function
-#endif
+ int do_locking,
+ const char *file, int lineno, const char *function
)
{
struct ast_hashtab *ht;
-#ifdef __AST_DEBUG_MALLOC
- if (!(ht = __ast_calloc(1, sizeof(*ht), file, lineno, function)))
-#else
- if (!(ht = ast_calloc(1, sizeof(*ht))))
-#endif
+ ht = __ast_calloc(1, sizeof(*ht), file, lineno, function);
+ if (!ht) {
return NULL;
+ }
while (!ast_is_prime(initial_buckets)) /* make sure this is prime */
initial_buckets++;
-#ifdef __AST_DEBUG_MALLOC
- if (!(ht->array = __ast_calloc(initial_buckets, sizeof(*(ht->array)), file, lineno, function))) {
-#else
- if (!(ht->array = ast_calloc(initial_buckets, sizeof(*(ht->array))))) {
-#endif
+ ht->array = __ast_calloc(initial_buckets, sizeof(*(ht->array)),
+ file, lineno, function);
+ if (!ht->array) {
ast_free(ht);
return NULL;
}
@@ -272,25 +258,19 @@ ast_hashtab_create
return ht;
}
-#ifdef __AST_DEBUG_MALLOC
struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func)
-#else
-struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj))
-#endif
{
struct ast_hashtab *ht;
unsigned int i;
- if (!(ht = ast_calloc(1, sizeof(*ht))))
+ ht = __ast_calloc(1, sizeof(*ht), file, lineno, func);
+ if (!ht) {
return NULL;
+ }
- if (!(ht->array =
-#ifdef __AST_DEBUG_MALLOC
- __ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)), file, lineno, func)
-#else
- ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)))
-#endif
- )) {
+ ht->array = __ast_calloc(tab->hash_tab_size, sizeof(*(ht->array)),
+ file, lineno, func);
+ if (!ht->array) {
ast_free(ht);
return NULL;
}
@@ -312,12 +292,9 @@ struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_fun
struct ast_hashtab_bucket *b = tab->array[i];
while (b) {
void *newobj = (*obj_dup_func)(b->object);
- if (newobj)
-#ifdef __AST_DEBUG_MALLOC
+ if (newobj) {
_ast_hashtab_insert_immediate_bucket(ht, newobj, i, file, lineno, func);
-#else
- ast_hashtab_insert_immediate_bucket(ht, newobj, i);
-#endif
+ }
b = b->next;
}
}
@@ -424,11 +401,7 @@ void ast_hashtab_destroy(struct ast_hashtab *tab, void (*objdestroyfunc)(void *o
}
}
-#ifdef __AST_DEBUG_MALLOC
int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
-#else
-int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
-#endif
{
unsigned int h;
int res=0;
@@ -441,11 +414,7 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
h = (*tab->hash)(obj) % tab->hash_tab_size;
-#ifdef __AST_DEBUG_MALLOC
res = _ast_hashtab_insert_immediate_bucket(tab, obj, h, file, lineno, func);
-#else
- res = ast_hashtab_insert_immediate_bucket(tab, obj, h);
-#endif
if (tab->do_locking)
ast_rwlock_unlock(&tab->lock);
@@ -453,11 +422,7 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj)
return res;
}
-#ifdef __AST_DEBUG_MALLOC
int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func)
-#else
-int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h)
-#endif
{
int c;
struct ast_hashtab_bucket *b;
@@ -471,13 +436,10 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj
if (c + 1 > tab->largest_bucket_size)
tab->largest_bucket_size = c + 1;
- if (!(b =
-#ifdef __AST_DEBUG_MALLOC
- __ast_calloc(1, sizeof(*b), file, lineno, func)
-#else
- ast_calloc(1, sizeof(*b))
-#endif
- )) return 0;
+ b = __ast_calloc(1, sizeof(*b), file, lineno, func);
+ if (!b) {
+ return 0;
+ }
b->object = obj;
b->next = tab->array[h];
@@ -495,11 +457,7 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj
return 1;
}
-#ifdef __AST_DEBUG_MALLOC
int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
-#else
-int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj)
-#endif
{
/* check to see if the element is already there; insert only if
it is not there. */
@@ -511,11 +469,7 @@ int ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj)
ast_rwlock_wrlock(&tab->lock);
if (!ast_hashtab_lookup_bucket(tab, obj, &bucket)) {
-#ifdef __AST_DEBUG_MALLOC
int ret2 = _ast_hashtab_insert_immediate_bucket(tab, obj, bucket, file, lineno, func);
-#else
- int ret2 = ast_hashtab_insert_immediate_bucket(tab, obj, bucket);
-#endif
if (tab->do_locking)
ast_rwlock_unlock(&tab->lock);
@@ -634,11 +588,7 @@ int ast_hashtab_capacity( struct ast_hashtab *tab)
/* the insert operation calls this, and is wrlock'd when it does. */
/* if you want to call it, you should set the wrlock yourself */
-#ifdef __AST_DEBUG_MALLOC
static void _ast_hashtab_resize(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
-#else
-static void ast_hashtab_resize(struct ast_hashtab *tab)
-#endif
{
/* this function is called either internally, when the resize func returns 1, or
externally by the user to force a resize of the hash table */
@@ -656,14 +606,10 @@ static void ast_hashtab_resize(struct ast_hashtab *tab)
tab->array[i] = 0; /* erase old ptrs */
}
ast_free(tab->array);
- if (!(tab->array =
-#ifdef __AST_DEBUG_MALLOC
- __ast_calloc(newsize, sizeof(*(tab->array)), file, lineno, func)
-#else
- ast_calloc(newsize, sizeof(*(tab->array)))
-#endif
- ))
+ tab->array = __ast_calloc(newsize, sizeof(*(tab->array)), file, lineno, func);
+ if (!tab->array) {
return;
+ }
/* now sort the buckets into their rightful new slots */
tab->resize_count++;
@@ -688,23 +634,15 @@ static void ast_hashtab_resize(struct ast_hashtab *tab)
}
}
-#ifdef __AST_DEBUG_MALLOC
struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
-#else
-struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab)
-#endif
{
/* returns an iterator */
struct ast_hashtab_iter *it;
- if (!(it =
-#ifdef __AST_DEBUG_MALLOC
- __ast_calloc(1, sizeof(*it), file, lineno, func)
-#else
- ast_calloc(1, sizeof(*it))
-#endif
- ))
+ it = __ast_calloc(1, sizeof(*it), file, lineno, func);
+ if (!it) {
return NULL;
+ }
it->next = tab->tlist;
it->tab = tab;
@@ -715,23 +653,15 @@ struct ast_hashtab_iter *ast_hashtab_start_traversal(struct ast_hashtab *tab)
}
/* use this function to get a write lock */
-#ifdef __AST_DEBUG_MALLOC
struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func)
-#else
-struct ast_hashtab_iter *ast_hashtab_start_write_traversal(struct ast_hashtab *tab)
-#endif
{
/* returns an iterator */
struct ast_hashtab_iter *it;
- if (!(it =
-#ifdef __AST_DEBUG_MALLOC
- __ast_calloc(1, sizeof(*it), file, lineno, func)
-#else
- ast_calloc(1, sizeof(*it))
-#endif
- ))
+ it = __ast_calloc(1, sizeof(*it), file, lineno, func);
+ if (!it) {
return NULL;
+ }
it->next = tab->tlist;
it->tab = tab;
diff --git a/main/heap.c b/main/heap.c
index b7d28ce2f..0b390f7b8 100644
--- a/main/heap.c
+++ b/main/heap.c
@@ -109,13 +109,8 @@ int ast_heap_verify(struct ast_heap *h)
return 0;
}
-#ifdef __AST_DEBUG_MALLOC
struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
- ssize_t index_offset, const char *file, int lineno, const char *func)
-#else
-struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn,
- ssize_t index_offset)
-#endif
+ ssize_t index_offset, const char *file, int lineno, const char *func)
{
struct ast_heap *h;
@@ -128,13 +123,8 @@ struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_f
init_height = 8;
}
- if (!(h =
-#ifdef __AST_DEBUG_MALLOC
- __ast_calloc(1, sizeof(*h), file, lineno, func)
-#else
- ast_calloc(1, sizeof(*h))
-#endif
- )) {
+ h = __ast_calloc(1, sizeof(*h), file, lineno, func);
+ if (!h) {
return NULL;
}
@@ -142,13 +132,8 @@ struct ast_heap *ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_f
h->index_offset = index_offset;
h->avail_len = (1 << init_height) - 1;
- if (!(h->heap =
-#ifdef __AST_DEBUG_MALLOC
- __ast_malloc(h->avail_len * sizeof(void *), file, lineno, func)
-#else
- ast_malloc(h->avail_len * sizeof(void *))
-#endif
- )) {
+ h->heap = __ast_malloc(h->avail_len * sizeof(void *), file, lineno, func);
+ if (!h->heap) {
ast_free(h);
return NULL;
}
@@ -173,20 +158,12 @@ struct ast_heap *ast_heap_destroy(struct ast_heap *h)
/*!
* \brief Add a row of additional storage for the heap.
*/
-static int grow_heap(struct ast_heap *h
-#ifdef __AST_DEBUG_MALLOC
-, const char *file, int lineno, const char *func
-#endif
-)
+static int grow_heap(struct ast_heap *h, const char *file, int lineno, const char *func)
{
void **new_heap;
size_t new_len = h->avail_len * 2 + 1;
-#ifdef __AST_DEBUG_MALLOC
new_heap = __ast_realloc(h->heap, new_len * sizeof(void *), file, lineno, func);
-#else
- new_heap = ast_realloc(h->heap, new_len * sizeof(void *));
-#endif
if (!new_heap) {
return -1;
}
@@ -242,17 +219,9 @@ static int bubble_up(struct ast_heap *h, int i)
return i;
}
-#ifdef __AST_DEBUG_MALLOC
int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func)
-#else
-int ast_heap_push(struct ast_heap *h, void *elm)
-#endif
{
- if (h->cur_len == h->avail_len && grow_heap(h
-#ifdef __AST_DEBUG_MALLOC
- , file, lineno, func
-#endif
- )) {
+ if (h->cur_len == h->avail_len && grow_heap(h, file, lineno, func)) {
return -1;
}
diff --git a/main/pbx_app.c b/main/pbx_app.c
index ec6bc7589..df8126c7f 100644
--- a/main/pbx_app.c
+++ b/main/pbx_app.c
@@ -275,7 +275,7 @@ static char *handle_show_application(struct ast_cli_entry *e, int cmd, struct as
* application at one time. You can type 'show application Dial Echo' and
* you will see informations about these two applications ...
*/
- return ast_complete_applications(a->line, a->word, a->n);
+ return ast_complete_applications(a->line, a->word, -1);
}
if (a->argc < 4) {
@@ -437,20 +437,23 @@ char *ast_complete_applications(const char *line, const char *word, int state)
AST_RWLIST_RDLOCK(&apps);
AST_RWLIST_TRAVERSE(&apps, app, list) {
cmp = strncasecmp(word, app->name, wordlen);
- if (cmp > 0) {
- continue;
- }
- if (!cmp) {
+ if (cmp < 0) {
+ /* No more matches. */
+ break;
+ } else if (!cmp) {
/* Found match. */
- if (++which <= state) {
- /* Not enough matches. */
- continue;
+ if (state != -1) {
+ if (++which <= state) {
+ /* Not enough matches. */
+ continue;
+ }
+ ret = ast_strdup(app->name);
+ break;
+ }
+ if (ast_cli_completion_add(ast_strdup(app->name))) {
+ break;
}
- ret = ast_strdup(app->name);
- break;
}
- /* Not in container. */
- break;
}
AST_RWLIST_UNLOCK(&apps);
diff --git a/main/strcompat.c b/main/strcompat.c
index c3b4ff180..0034c2177 100644
--- a/main/strcompat.c
+++ b/main/strcompat.c
@@ -25,6 +25,7 @@
<support_level>core</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include <ctype.h>
@@ -139,7 +140,7 @@ size_t strnlen(const char *s, size_t n)
}
#endif /* !HAVE_STRNLEN */
-#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_STRNDUP)
char *strndup(const char *s, size_t n)
{
size_t len = strnlen(s, n);
@@ -151,9 +152,9 @@ char *strndup(const char *s, size_t n)
new[len] = '\0';
return memcpy(new, s, len);
}
-#endif /* !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) */
+#endif /* !defined(HAVE_STRNDUP) */
-#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_VASPRINTF)
int vasprintf(char **strp, const char *fmt, va_list ap)
{
int size;
@@ -171,7 +172,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
return size;
}
-#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
+#endif /* !defined(HAVE_VASPRINTF) */
#ifndef HAVE_TIMERSUB
void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff)
@@ -205,7 +206,7 @@ void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tv
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_ASPRINTF)
int asprintf(char **str, const char *fmt, ...)
{
va_list ap;
@@ -218,7 +219,7 @@ int asprintf(char **str, const char *fmt, ...)
return ret;
}
-#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
+#endif /* !defined(HAVE_ASPRINTF) */
#ifndef HAVE_STRTOQ
#ifndef LONG_MIN
diff --git a/main/stringfields.c b/main/stringfields.c
index 7e52bbc9e..30aa8cddd 100644
--- a/main/stringfields.c
+++ b/main/stringfields.c
@@ -55,12 +55,6 @@ static size_t optimal_alloc_size(size_t size)
return (1 << count) - ALLOCATOR_OVERHEAD;
}
-static void *calloc_wrapper(unsigned int num_structs, size_t struct_size,
- const char *file, int lineno, const char *func)
-{
- return __ast_calloc(num_structs, struct_size, file, lineno, func);
-}
-
/*! \brief add a new block to the pool.
* We can only allocate from the topmost pool, so the
* fields in *mgr reflect the size of that only.
@@ -71,7 +65,8 @@ static int add_string_pool(struct ast_string_field_mgr *mgr, struct ast_string_f
struct ast_string_field_pool *pool;
size_t alloc_size = optimal_alloc_size(sizeof(*pool) + size);
- if (!(pool = calloc_wrapper(1, alloc_size, file, lineno, func))) {
+ pool = __ast_calloc(1, alloc_size, file, lineno, func);
+ if (!pool) {
return -1;
}
@@ -184,11 +179,11 @@ int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_
}
mgr->last_alloc = NULL;
-#if defined(__AST_DEBUG_MALLOC)
+ /* v-- MALLOC_DEBUG information */
mgr->owner_file = file;
mgr->owner_func = func;
mgr->owner_line = lineno;
-#endif
+ /* ^-- MALLOC_DEBUG information */
if (AST_VECTOR_INIT(&mgr->string_fields, initial_vector_size)) {
return -1;
@@ -227,13 +222,10 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr
new_size *= 2;
}
-#if defined(__AST_DEBUG_MALLOC)
- if (add_string_pool(mgr, pool_head, new_size, mgr->owner_file, mgr->owner_line, mgr->owner_func))
- return NULL;
-#else
- if (add_string_pool(mgr, pool_head, new_size, __FILE__, __LINE__, __FUNCTION__))
+ if (add_string_pool(mgr, pool_head, new_size,
+ mgr->owner_file, mgr->owner_line, mgr->owner_func)) {
return NULL;
-#endif
+ }
}
/* pool->base is always aligned (gcc aligned attribute). We ensure that
@@ -388,8 +380,8 @@ void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr,
}
void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_size,
- size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size, const char *file,
- int lineno, const char *func)
+ size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size,
+ const char *file, int lineno, const char *func)
{
struct ast_string_field_mgr *mgr;
struct ast_string_field_pool *pool;
@@ -402,7 +394,8 @@ void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_siz
ast_assert(num_structs == 1);
- if (!(allocation = calloc_wrapper(num_structs, size_to_alloc, file, lineno, func))) {
+ allocation = __ast_calloc(num_structs, size_to_alloc, file, lineno, func);
+ if (!allocation) {
return NULL;
}
@@ -426,11 +419,11 @@ void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_siz
mgr->embedded_pool = pool;
*pool_head = pool;
pool->size = size_to_alloc - struct_size - sizeof(*pool);
-#if defined(__AST_DEBUG_MALLOC)
- mgr->owner_file = file;
- mgr->owner_func = func;
- mgr->owner_line = lineno;
-#endif
+ /* v-- MALLOC_DEBUG information */
+ mgr->owner_file = file;
+ mgr->owner_func = func;
+ mgr->owner_line = lineno;
+ /* ^-- MALLOC_DEBUG information */
return allocation;
}
diff --git a/main/strings.c b/main/strings.c
index ad96df249..640af6123 100644
--- a/main/strings.c
+++ b/main/strings.c
@@ -52,13 +52,9 @@
* ast_str_append_va(...)
*/
-#ifdef __AST_DEBUG_MALLOC
-int __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len,
- int append, const char *fmt, va_list ap, const char *file, int lineno, const char *function)
-#else
int __ast_str_helper(struct ast_str **buf, ssize_t max_len,
- int append, const char *fmt, va_list ap)
-#endif
+ int append, const char *fmt, va_list ap,
+ const char *file, int lineno, const char *function)
{
int res;
int added;
@@ -110,13 +106,7 @@ int __ast_str_helper(struct ast_str **buf, ssize_t max_len,
need = max_len;
}
- if (
-#ifdef __AST_DEBUG_MALLOC
- _ast_str_make_space(buf, need, file, lineno, function)
-#else
- ast_str_make_space(buf, need)
-#endif
- ) {
+ if (_ast_str_make_space(buf, need, file, lineno, function)) {
ast_log_safe(LOG_VERBOSE, "failed to extend from %d to %d\n",
(int) (*buf)->__AST_STR_LEN, need);
diff --git a/main/utils.c b/main/utils.c
index 928b89bc5..c2e07fccf 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -2322,28 +2322,6 @@ int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request,
return 0;
}
-#ifndef __AST_DEBUG_MALLOC
-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);
- res = vasprintf(ret, fmt, ap);
- 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;
-}
-#endif
-
int ast_get_tid(void)
{
int ret = -1;
diff --git a/menuselect/strcompat.c b/menuselect/strcompat.c
index c25609f4b..b78061ca3 100644
--- a/menuselect/strcompat.c
+++ b/menuselect/strcompat.c
@@ -138,7 +138,7 @@ size_t strnlen(const char *s, size_t n)
}
#endif /* !HAVE_STRNLEN */
-#if !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_STRNDUP)
char *strndup(const char *s, size_t n)
{
size_t len = strnlen(s, n);
@@ -150,9 +150,9 @@ char *strndup(const char *s, size_t n)
new[len] = '\0';
return memcpy(new, s, len);
}
-#endif /* !defined(HAVE_STRNDUP) && !defined(__AST_DEBUG_MALLOC) */
+#endif /* !defined(HAVE_STRNDUP) */
-#if !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_VASPRINTF)
int vasprintf(char **strp, const char *fmt, va_list ap)
{
int size;
@@ -170,7 +170,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
return size;
}
-#endif /* !defined(HAVE_VASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
+#endif /* !defined(HAVE_VASPRINTF) */
/*
* Based on Code from bsd-asprintf from OpenSSH
@@ -191,7 +191,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC)
+#if !defined(HAVE_ASPRINTF)
int asprintf(char **str, const char *fmt, ...)
{
va_list ap;
@@ -204,7 +204,7 @@ int asprintf(char **str, const char *fmt, ...)
return ret;
}
-#endif /* !defined(HAVE_ASPRINTF) && !defined(__AST_DEBUG_MALLOC) */
+#endif /* !defined(HAVE_ASPRINTF) */
#ifndef HAVE_GETLOADAVG
#ifdef linux
diff --git a/res/res_pjsip_rfc3326.c b/res/res_pjsip_rfc3326.c
index 5ac16f024..76b0d08b0 100644
--- a/res/res_pjsip_rfc3326.c
+++ b/res/res_pjsip_rfc3326.c
@@ -35,32 +35,35 @@
static void rfc3326_use_reason_header(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
- const pj_str_t str_reason = { "Reason", 6 };
- pjsip_generic_string_hdr *header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL);
- char buf[20], *cause, *text;
+ static const pj_str_t str_reason = { "Reason", 6 };
+ pjsip_generic_string_hdr *header;
+ char buf[20];
+ char *cause;
+ char *text;
int code;
- if (!header) {
- return;
- }
+ header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL);
+ for (; header;
+ header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, header->next)) {
+ ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));
+ cause = ast_skip_blanks(buf);
- ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));
- cause = ast_skip_blanks(buf);
+ if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) {
+ continue;
+ }
- if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) {
- return;
- }
+ /* If text is present get rid of it */
+ if ((text = strstr(cause, ";"))) {
+ *text = '\0';
+ }
- /* If text is present get rid of it */
- if ((text = strstr(cause, ";"))) {
- *text = '\0';
- }
+ if (sscanf(cause, "cause=%30d", &code) != 1) {
+ continue;
+ }
- if (sscanf(cause, "cause=%30d", &code) != 1) {
- return;
+ ast_channel_hangupcause_set(session->channel, code & 0x7f);
+ break;
}
-
- ast_channel_hangupcause_set(session->channel, code & 0x7f);
}
static int rfc3326_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
diff --git a/res/res_srtp.c b/res/res_srtp.c
index 1077f2337..cda1291fa 100644
--- a/res/res_srtp.c
+++ b/res/res_srtp.c
@@ -41,7 +41,6 @@
#if HAVE_SRTP_VERSION > 1
# include <srtp2/srtp.h>
-# include <srtp2/crypto_types.h>
# include "srtp/srtp_compat.h"
# include <openssl/rand.h>
#else
diff --git a/res/stasis_recording/stored.c b/res/stasis_recording/stored.c
index ac216ff8c..909524e8f 100644
--- a/res/stasis_recording/stored.c
+++ b/res/stasis_recording/stored.c
@@ -123,18 +123,9 @@ static int split_path(const char *path, char **dir, char **file)
return -1;
}
-#if defined(__AST_DEBUG_MALLOC)
*dir = ast_strdup(real_dir); /* Dupe so we can ast_free() */
-#else
- /*
- * ast_std_free() and ast_free() are the same thing at this time
- * so we don't need to dupe.
- */
- *dir = real_dir;
- real_dir = NULL;
-#endif /* defined(__AST_DEBUG_MALLOC) */
*file = ast_strdup(file_portion);
- return 0;
+ return (*dir && *file) ? 0 : -1;
}
struct match_recording_data {
diff --git a/sounds/Makefile b/sounds/Makefile
index 779d52a8e..606bbdcec 100644
--- a/sounds/Makefile
+++ b/sounds/Makefile
@@ -127,9 +127,9 @@ have_download:
@if test "$(DOWNLOAD)" = ":" ; then \
echo "**************************************************"; \
echo "*** ***"; \
- echo "*** You must have either wget or fetch to be ***"; \
- echo "*** able to automatically download and install ***"; \
- echo "*** the requested sound packages. ***"; \
+ echo "*** You must have either wget, curl, or fetch ***"; \
+ echo "*** to be able to automatically download and ***"; \
+ echo "*** install the requested sound packages. ***"; \
echo "*** ***"; \
echo "*** Please install one of these, or remove any ***"; \
echo "*** extra sound package selections in ***"; \
diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile
index f7b9f0c3f..b95b33221 100644
--- a/third-party/pjproject/Makefile
+++ b/third-party/pjproject/Makefile
@@ -66,9 +66,9 @@ ifeq ($(SPECIAL_TARGETS),)
endif
ifeq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),MALLOC_DEBUG)
CF += -DMALLOC_DEBUG
- MALLOC_DEBUG_LIBS = source/pjsip-apps/lib/libasterisk_malloc_debug.a
- MALLOC_DEBUG_LDFLAGS = -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive
endif
+ MALLOC_DEBUG_LIBS = source/pjsip-apps/lib/libasterisk_malloc_debug.a
+ MALLOC_DEBUG_LDFLAGS = -L$(PJDIR)/pjsip-apps/lib -Wl,-whole-archive -lasterisk_malloc_debug -Wl,-no-whole-archive
ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),)
CF += -O3
endif
diff --git a/third-party/pjproject/configure.m4 b/third-party/pjproject/configure.m4
index c1edaf9aa..42482b2e5 100644
--- a/third-party/pjproject/configure.m4
+++ b/third-party/pjproject/configure.m4
@@ -16,7 +16,7 @@ AC_DEFUN([_PJPROJECT_CONFIGURE],
AC_MSG_RESULT(configuring)
if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then
- AC_MSG_ERROR(A download utility (wget, curl or fetch) is required to download bundled pjproject)
+ AC_MSG_ERROR(A download utility (wget, curl, or fetch) is required to download bundled pjproject)
fi
if test "${BZIP2}" = ":" ; then
AC_MSG_ERROR(bzip2 is required to extract the pjproject tar file)
diff --git a/third-party/pjproject/patches/asterisk_malloc_debug.c b/third-party/pjproject/patches/asterisk_malloc_debug.c
index aaf79855a..061bdd491 100644
--- a/third-party/pjproject/patches/asterisk_malloc_debug.c
+++ b/third-party/pjproject/patches/asterisk_malloc_debug.c
@@ -22,7 +22,7 @@
#include <string.h>
#include <stdarg.h>
-int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
+int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
{
va_list ap;
int rc = 0;
@@ -34,7 +34,7 @@ int __ast_asprintf(const char *file, int lineno, const char *func, char **strp,
return rc;
}
-void *__ast_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)
{
return calloc(nmemb, size);
}
@@ -44,27 +44,27 @@ void __ast_free(void *ptr, const char *file, int lineno, const char *func)
free(ptr);
}
-void *__ast_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)
{
return malloc(size);
}
-void *__ast_realloc(void *ptr, size_t size, 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)
{
return realloc(ptr, size);
}
-char *__ast_strdup(const char *s, const char *file, int lineno, const char *func)
+char *__ast_repl_strdup(const char *s, const char *file, int lineno, const char *func)
{
return strdup(s);
}
-char *__ast_strndup(const char *s, size_t n, 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)
{
return strndup(s, n);
}
-int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
+int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
{
return vasprintf(strp, format, ap);
}
diff --git a/third-party/pjproject/patches/asterisk_malloc_debug.h b/third-party/pjproject/patches/asterisk_malloc_debug.h
index 44c473758..e5e04f1af 100644
--- a/third-party/pjproject/patches/asterisk_malloc_debug.h
+++ b/third-party/pjproject/patches/asterisk_malloc_debug.h
@@ -25,15 +25,15 @@
extern "C" {
#endif
-int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
+int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
__attribute__((format(printf, 5, 6)));
-void *__ast_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);
void __ast_free(void *ptr, const char *file, int lineno, const char *func);
-void *__ast_malloc(size_t size, 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);
-char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
-int __ast_vasprintf(char **strp, const char *format, va_list ap, 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_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);
+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)));
/* Undefine any macros */
@@ -48,28 +48,28 @@ int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *fil
/* Provide our own definitions */
#define asprintf(a, b, c...) \
- __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
+ __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
#define calloc(a,b) \
- __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_repl_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#define free(a) \
__ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#define malloc(a) \
- __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_repl_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#define realloc(a,b) \
- __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_repl_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#define strdup(a) \
- __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_repl_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#define strndup(a,b) \
- __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_repl_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#define vasprintf(a,b,c) \
- __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+ __ast_repl_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#ifdef __cplusplus
}
diff --git a/third-party/pjproject/patches/config_site.h b/third-party/pjproject/patches/config_site.h
index d5aee82cc..67e3451d0 100644
--- a/third-party/pjproject/patches/config_site.h
+++ b/third-party/pjproject/patches/config_site.h
@@ -8,7 +8,7 @@
* Since both pjproject and asterisk source files will include config_site.h,
* we need to make sure that only pjproject source files include asterisk_malloc_debug.h.
*/
-#if defined(MALLOC_DEBUG) && !defined(_ASTERISK_ASTMM_H)
+#if !defined(_ASTERISK_ASTMM_H)
#include "asterisk_malloc_debug.h"
#endif
diff --git a/utils/extconf.c b/utils/extconf.c
index 1be739c17..5b3a95be9 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -780,7 +780,7 @@ void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, i
__ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
AST_INLINE_API(
-void * attribute_malloc __ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
+void *__ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
{
void *newp;