[asterisk-commits] Fix error's produced by astmm.h when standard allocators are... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 11 05:34:06 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: Fix error's produced by astmm.h when standard allocators are used.
......................................................................


Fix error's produced by astmm.h when standard allocators are used.

astmm.h includes defines that are meant to cause error's when standard
allocators (malloc, calloc, free, etc) are used.  It actually only
causes a warning, which is not always caught on certain sources.  In
modules this unknown symbol is not detected until runtime, where the
module fails to load.  This modifies the define's so that using one
of the blocked functions will cause a compile error regardless of
CFLAGS.

Moved spandsp header includes to before asterisk.h so the static inline
functions can continue using malloc and free.  Although these functions
are never called and optimized away, the updated replacement macro's
would still cause a failure.

Change-Id: I532640aca0913ba9da3b18c04a0f010ca1715af5
---
M include/asterisk/astmm.h
M res/res_fax_spandsp.c
2 files changed, 14 insertions(+), 12 deletions(-)

Approvals:
  Matt Jordan: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Verified



diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h
index 6086509..1d778d4 100644
--- a/include/asterisk/astmm.h
+++ b/include/asterisk/astmm.h
@@ -95,21 +95,21 @@
 	__ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
 #else
 #define calloc(a,b) \
-	Do_not_use_calloc__use_ast_calloc(a,b)
+	Do_not_use_calloc__use_ast_calloc->fail(a,b)
 #define malloc(a) \
-	Do_not_use_malloc__use_ast_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(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(a,b)
+	Do_not_use_realloc__use_ast_realloc->fail(a,b)
 #define strdup(a) \
-	Do_not_use_strdup__use_ast_strdup(a)
+	Do_not_use_strdup__use_ast_strdup->fail(a)
 #define strndup(a,b) \
-	Do_not_use_strndup__use_ast_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(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(a,b,c)
+	Do_not_use_vasprintf__use_ast_vasprintf->fail(a,b,c)
 #endif
 
 /* Provide our own definitions */
diff --git a/res/res_fax_spandsp.c b/res/res_fax_spandsp.c
index 288f91d..4249227 100644
--- a/res/res_fax_spandsp.c
+++ b/res/res_fax_spandsp.c
@@ -48,14 +48,16 @@
 	<support_level>extended</support_level>
 ***/
 
-#include "asterisk.h"
-
-ASTERISK_REGISTER_FILE()
-
+/* Include spandsp headers before asterisk.h so the inline functions can continue using
+ * malloc and free, even with MALLOC_DEBUG enabled. */
 #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
 #include <spandsp.h>
 #include <spandsp/version.h>
 
+#include "asterisk.h"
+
+ASTERISK_REGISTER_FILE()
+
 #include "asterisk/logger.h"
 #include "asterisk/module.h"
 #include "asterisk/strings.h"

-- 
To view, visit https://gerrit.asterisk.org/417
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I532640aca0913ba9da3b18c04a0f010ca1715af5
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list