summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/.gitignore1
-rw-r--r--utils/Makefile17
-rw-r--r--utils/ael_main.c1
-rw-r--r--utils/astman.c1
-rw-r--r--utils/check_expr.c1
-rw-r--r--utils/conf2ael.c1
-rw-r--r--utils/extconf.c221
7 files changed, 16 insertions, 227 deletions
diff --git a/utils/.gitignore b/utils/.gitignore
index dbdc6b6d2..7840265e5 100644
--- a/utils/.gitignore
+++ b/utils/.gitignore
@@ -3,6 +3,7 @@ aelparse
aelparse.c
ast_expr2.c
ast_expr2f.c
+astmm.c
astman
astcanary
astdb2bdb
diff --git a/utils/Makefile b/utils/Makefile
index 3a1275407..d62d45f4f 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -86,7 +86,7 @@ clean:
rm -f *.o $(ALL_UTILS) check_expr
rm -f .*.d
rm -f *.s *.i
- rm -f md5.c strcompat.c ast_expr2.c ast_expr2.h ast_expr2f.c pbx_ael.c pval.c hashtab.c lock.c
+ rm -f astmm.c md5.c strcompat.c ast_expr2.c ast_expr2.h ast_expr2f.c pbx_ael.c pval.c hashtab.c lock.c
rm -f aelparse.c aelbison.c conf2ael
rm -f threadstorage.c
rm -f utils.c strings.c poll.c version.c sha1.c astobj2.c refcounter
@@ -100,11 +100,14 @@ md5.c: $(ASTTOPDIR)/main/md5.c
astman: astman.o md5.o
astman: LIBS+=$(NEWT_LIB)
-astman.o: _ASTCFLAGS+=-DNO_MALLOC_DEBUG
stereorize: stereorize.o frame.o
stereorize: LIBS+=-lm
+astmm.c: $(ASTTOPDIR)/main/astmm.c
+ $(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
+ $(CMD_PREFIX) cp "$<" "$@"
+
hashtab.c: $(ASTTOPDIR)/main/hashtab.c
$(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
$(CMD_PREFIX) cp "$<" "$@"
@@ -134,7 +137,7 @@ ast_expr2f.c: $(ASTTOPDIR)/main/ast_expr2f.c
$(CMD_PREFIX) cp "$<" "$@"
ast_expr2f.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/main -Wno-unused
-check_expr: check_expr.o ast_expr2.o ast_expr2f.o strcompat.o threadstorage.o clicompat.o
+check_expr: check_expr.o ast_expr2.o ast_expr2f.o strcompat.o threadstorage.o clicompat.o astmm.o
aelbison.c: $(ASTTOPDIR)/res/ael/ael.tab.c
$(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
@@ -162,7 +165,7 @@ aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c
aelparse.o: _ASTCFLAGS+=-I$(ASTTOPDIR)/res -Wno-unused
aelparse: LIBS+=-lm
-aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o lock.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o
+aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o lock.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o astmm.o
threadstorage.c: $(ASTTOPDIR)/main/threadstorage.c
$(ECHO_PREFIX) echo " [CP] $(subst $(ASTTOPDIR)/,,$<) -> $@"
@@ -171,15 +174,15 @@ threadstorage.c: $(ASTTOPDIR)/main/threadstorage.c
extconf.o: extconf.c
-conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o lock.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o
+conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o lock.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o astmm.o
-check_expr2: $(ASTTOPDIR)/main/ast_expr2f.c $(ASTTOPDIR)/main/ast_expr2.c $(ASTTOPDIR)/main/ast_expr2.h
+check_expr2: $(ASTTOPDIR)/main/ast_expr2f.c $(ASTTOPDIR)/main/ast_expr2.c $(ASTTOPDIR)/main/ast_expr2.h astmm.o
$(ECHO_PREFIX) echo " [CC] ast_expr2f.c -> ast_expr2fz.o"
$(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE $(ASTTOPDIR)/main/ast_expr2f.c -o ast_expr2fz.o
$(ECHO_PREFIX) echo " [CC] ast_expr2.c -> ast_expr2z.o"
$(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE2 $(ASTTOPDIR)/main/ast_expr2.c -o ast_expr2z.o
$(ECHO_PREFIX) echo " [LD] ast_expr2fz.o ast_expr2z.o -> check_expr2"
- $(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.o -lm
+ $(CC) -g -o check_expr2 ast_expr2fz.o ast_expr2z.o astmm.o -lm
$(ECHO_PREFIX) echo " [RM] ast_expr2fz.o ast_expr2z.o"
rm ast_expr2z.o ast_expr2fz.o
./check_expr2 expr2.testinput
diff --git a/utils/ael_main.c b/utils/ael_main.c
index 3a91ef167..f4521e183 100644
--- a/utils/ael_main.c
+++ b/utils/ael_main.c
@@ -11,6 +11,7 @@
<support_level>extended</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include <locale.h>
diff --git a/utils/astman.c b/utils/astman.c
index af3185104..d4757d026 100644
--- a/utils/astman.c
+++ b/utils/astman.c
@@ -26,6 +26,7 @@
<support_level>extended</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include <newt.h>
diff --git a/utils/check_expr.c b/utils/check_expr.c
index 1e4b9d175..d4a4c900f 100644
--- a/utils/check_expr.c
+++ b/utils/check_expr.c
@@ -20,6 +20,7 @@
<support_level>extended</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include "asterisk/ast_expr.h"
diff --git a/utils/conf2ael.c b/utils/conf2ael.c
index a8371bbec..e3a905690 100644
--- a/utils/conf2ael.c
+++ b/utils/conf2ael.c
@@ -27,6 +27,7 @@
<support_level>extended</support_level>
***/
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#include "asterisk/paths.h" /* CONFIG_DIR */
diff --git a/utils/extconf.c b/utils/extconf.c
index 6826f4f99..541cbf800 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -43,7 +43,7 @@
<support_level>extended</support_level>
***/
-#define ASTMM_LIBC ASTMM_REDIRECT
+#define ASTMM_LIBC ASTMM_IGNORE
#include "asterisk.h"
#undef DEBUG_THREADS
@@ -681,9 +681,6 @@ int ast_channel_trylock(struct ast_channel *chan);
/* from utils.h */
-#define ast_free free
-#define ast_free_ptr free
-
struct ast_flags { /* stolen from utils.h */
unsigned int flags;
};
@@ -704,222 +701,6 @@ struct ast_flags { /* stolen from utils.h */
(p)->flags &= ~(flag); \
} while (0)
-
-
-#define MALLOC_FAILURE_MSG \
- ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
-
-/*!
- * \brief A wrapper for malloc()
- *
- * ast_malloc() is a wrapper for malloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The argument and return value are the same as malloc()
- */
-#define ast_malloc(len) \
- __ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, const char *func),
-{
- void *p;
-
- if (!(p = malloc(len)))
- MALLOC_FAILURE_MSG;
-
- return p;
-}
-)
-
-/*!
- * \brief A wrapper for calloc()
- *
- * ast_calloc() is a wrapper for calloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as calloc()
- */
-#define ast_calloc(num, len) \
- __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func),
-{
- void *p;
-
- if (!(p = calloc(num, len)))
- MALLOC_FAILURE_MSG;
-
- return p;
-}
-)
-
-/*!
- * \brief A wrapper for calloc() for use in cache pools
- *
- * ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log
- * message in the case that the allocation fails. When memory debugging is in use,
- * the memory allocated by this function will be marked as 'cache' so it can be
- * distinguished from normal memory allocations.
- *
- * The arguments and return value are the same as calloc()
- */
-#define ast_calloc_cache(num, len) \
- __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-/*!
- * \brief A wrapper for realloc()
- *
- * ast_realloc() is a wrapper for realloc() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as realloc()
- */
-#define ast_realloc(p, len) \
- __ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-void *__ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
-{
- void *newp;
-
- if (!(newp = realloc(p, len)))
- MALLOC_FAILURE_MSG;
-
- return newp;
-}
-)
-
-/*!
- * \brief A wrapper for strdup()
- *
- * ast_strdup() is a wrapper for strdup() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL
- * argument is provided, ast_strdup will return NULL without generating any
- * kind of error log message.
- *
- * The argument and return value are the same as strdup()
- */
-#define ast_strdup(str) \
- __ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-char * attribute_malloc __ast_strdup(const char *str, const char *file, int lineno, const char *func),
-{
- char *newstr = NULL;
-
- if (str) {
- if (!(newstr = strdup(str)))
- MALLOC_FAILURE_MSG;
- }
-
- return newstr;
-}
-)
-
-/*!
- * \brief A wrapper for strndup()
- *
- * ast_strndup() is a wrapper for strndup() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * ast_strndup(), unlike strndup(), can safely accept a NULL argument for the
- * string to duplicate. If a NULL argument is provided, ast_strdup will return
- * NULL without generating any kind of error log message.
- *
- * The arguments and return value are the same as strndup()
- */
-#define ast_strndup(str, len) \
- __ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func),
-{
- char *newstr = NULL;
-
- if (str) {
- if (!(newstr = strndup(str, len)))
- MALLOC_FAILURE_MSG;
- }
-
- return newstr;
-}
-)
-
-/*!
- * \brief A wrapper for asprintf()
- *
- * ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as asprintf()
- */
-#define ast_asprintf(ret, fmt, ...) \
- __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__)
-
-AST_INLINE_API(
-__attribute__((format(printf, 5, 6)))
-int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...),
-{
- int res;
- va_list ap;
-
- va_start(ap, fmt);
- if ((res = vasprintf(ret, fmt, ap)) == -1)
- MALLOC_FAILURE_MSG;
- va_end(ap);
-
- return res;
-}
-)
-
-/*!
- * \brief A wrapper for vasprintf()
- *
- * ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log
- * message in the case that the allocation fails.
- *
- * The arguments and return value are the same as vasprintf()
- */
-#define ast_vasprintf(ret, fmt, ap) \
- __ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-
-AST_INLINE_API(
-__attribute__((format(printf, 2, 0)))
-int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, int lineno, const char *func),
-{
- int res;
-
- if ((res = vasprintf(ret, fmt, ap)) == -1)
- MALLOC_FAILURE_MSG;
-
- return res;
-}
-)
-
-#if !defined(ast_strdupa) && defined(__GNUC__)
-/*!
- \brief duplicate a string in memory from the stack
- \param s The string to duplicate
-
- This macro will duplicate the given string. It returns a pointer to the stack
- allocatted memory for the new string.
-*/
-#define ast_strdupa(s) \
- (__extension__ \
- ({ \
- const char *__old = (s); \
- size_t __len = strlen(__old) + 1; \
- char *__new = __builtin_alloca(__len); \
- memcpy (__new, __old, __len); \
- __new; \
- }))
-#endif
-
-
/* from config.c */
#define MAX_NESTED_COMMENTS 128