core: Don't allow free to mean ast_free (and malloc, etc..).

This gets rid of most old libc free/malloc/realloc and replaces them
with ast_free and friends. When compiling with MALLOC_DEBUG you'll
notice it when you're mistakenly using one of the libc variants. For
the legacy cases you can define WRAP_LIBC_MALLOC before including
asterisk.h.

Even better would be if the errors were also enabled when compiling
without MALLOC_DEBUG, but that's a slightly more invasive header
file change.

Those compiling addons/format_mp3 will need to rerun
./contrib/scripts/get_mp3_source.sh.

ASTERISK-24348 #related
Review: https://reviewboard.asterisk.org/r/4015/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423978 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Walter Doekes
2014-09-26 14:41:38 +00:00
parent b8c1130ed1
commit 37179a2b1f
44 changed files with 375 additions and 341 deletions

View File

@@ -19,6 +19,7 @@
*/
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include <stdlib.h>
/* #ifdef HAVE_MALLOC_H
@@ -126,10 +127,10 @@ void printBitStrValue (ASN1UINT numbits, const ASN1OCTET* data)
indent ();
OOTRACEDBGB2("%s\n", bitStrToString (numbits, data, s, numbits+8));
#else
char* s = (char*)malloc(numbits + 8);
char* s = ast_malloc(numbits + 8);
indent ();
OOTRACEDBGB2("%s\n", bitStrToString (numbits, data, s, numbits+8));
free(s);
ast_free(s);
#endif
}
@@ -141,10 +142,10 @@ void printOctStrValue (ASN1UINT numocts, const ASN1OCTET* data)
indent ();
OOTRACEDBGB2 ("%s\n", octStrToString (numocts, data, s, bufsiz));
#else
char* s = (char*)malloc(bufsiz);
char* s = ast_malloc(bufsiz);
indent ();
OOTRACEDBGB2 ("%s\n", octStrToString (numocts, data, s, bufsiz));
free(s);
ast_free(s);
#endif
}