summaryrefslogtreecommitdiff
path: root/include/asterisk/astmm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asterisk/astmm.h')
-rw-r--r--include/asterisk/astmm.h67
1 files changed, 35 insertions, 32 deletions
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!!"