core: Remove ABI effects of MALLOC_DEBUG.

This allows asterisk to be compiled with MALLOC_DEBUG to load modules
built without MALLOC_DEBUG.  Now pre-compiled third-party modules will
still work regardless of MALLOC_DEBUG being enabled or not.

Change-Id: Ic07ad80b2c2df894db984cf27b16a69383ce0e10
This commit is contained in:
Richard Mudgett
2018-02-19 19:55:50 -06:00
parent e58ae393b1
commit c711e4076a
29 changed files with 390 additions and 485 deletions

View File

@@ -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