30 #ifndef _ASTERISK_ASTMM_H 31 #define _ASTERISK_ASTMM_H 50 void __ast_free(
void *ptr,
const char *
file,
int lineno,
const char *func);
51 void *
__ast_realloc(
void *ptr,
size_t size,
const char *
file,
int lineno,
const char *func);
55 __attribute__((format(printf, 5, 6)));
56 int __ast_vasprintf(
char **strp, const
char *format, va_list ap, const
char *file,
int lineno, const
char *func)
57 __attribute__((format(printf, 2, 0)));
61 void *
__ast_repl_calloc(
size_t nmemb,
size_t size, const
char *file,
int lineno, const
char *func) attribute_malloc;
62 void *
__ast_repl_malloc(
size_t size, const
char *file,
int lineno, const
char *func) attribute_malloc;
63 void *
__ast_repl_realloc(
void *ptr,
size_t size, const
char *file,
int lineno, const
char *func);
64 char *
__ast_repl_strdup(const
char *s, const
char *file,
int lineno, const
char *func) attribute_malloc;
65 char *
__ast_repl_strndup(const
char *s,
size_t n, const
char *file,
int lineno, const
char *func) attribute_malloc;
66 int __ast_repl_asprintf(const
char *file,
int lineno, const
char *func,
char **strp, const
char *format, ...)
67 __attribute__((format(printf, 5, 6)));
68 int __ast_repl_vasprintf(
char **strp, const
char *format, va_list ap, const
char *file,
int lineno, const
char *func)
69 __attribute__((format(printf, 2, 0)));
99 #define ASTMM_REDIRECT 1 109 #define ASTMM_IGNORE 2 115 #if !defined(ASTMM_LIBC) 117 #define ASTMM_LIBC ASTMM_BLOCK 120 #if ASTMM_LIBC == ASTMM_IGNORE 134 #if ASTMM_LIBC == ASTMM_REDIRECT 137 #define calloc(nmemb, size) \ 138 __ast_repl_calloc(nmemb, size, __FILE__, __LINE__, __PRETTY_FUNCTION__) 139 #define malloc(size) \ 140 __ast_repl_malloc(size, __FILE__, __LINE__, __PRETTY_FUNCTION__) 142 __ast_free(ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__) 143 #define realloc(ptr, size) \ 144 __ast_repl_realloc(ptr, size, __FILE__, __LINE__, __PRETTY_FUNCTION__) 146 __ast_repl_strdup(s, __FILE__, __LINE__, __PRETTY_FUNCTION__) 147 #define strndup(s, n) \ 148 __ast_repl_strndup(s, n, __FILE__, __LINE__, __PRETTY_FUNCTION__) 149 #define asprintf(strp, format, args...) \ 150 __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, strp, format, args) 151 #define vasprintf(strp, format, ap) \ 152 __ast_repl_vasprintf(strp, format, ap, __FILE__, __LINE__, __PRETTY_FUNCTION__) 154 #elif ASTMM_LIBC == ASTMM_BLOCK 157 #define calloc(a, b) \ 158 Do_not_use_calloc__use_ast_calloc->fail(a, b) 160 Do_not_use_malloc__use_ast_malloc->fail(a) 162 Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a) 163 #define realloc(a, b) \ 164 Do_not_use_realloc__use_ast_realloc->fail(a, b) 166 Do_not_use_strdup__use_ast_strdup->fail(a) 167 #define strndup(a, b) \ 168 Do_not_use_strndup__use_ast_strndup->fail(a, b) 169 #define asprintf(a, b, c...) \ 170 Do_not_use_asprintf__use_ast_asprintf->fail(a, b, c) 171 #define vasprintf(a, b, c) \ 172 Do_not_use_vasprintf__use_ast_vasprintf->fail(a, b, c) 175 #error "Unacceptable value for the macro ASTMM_LIBC" 182 #define ast_free(a) \ 183 __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) 193 #define ast_malloc(len) \ 194 __ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__) 204 #define ast_calloc(num, len) \ 205 __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) 217 #define ast_calloc_cache(num, len) \ 218 __ast_calloc_cache((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) 228 #define ast_realloc(p, len) \ 229 __ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) 243 #define ast_strdup(str) \ 244 __ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__) 258 #define ast_strndup(str, len) \ 259 __ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) 269 #define ast_asprintf(ret, fmt, ...) \ 270 __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__) 280 #define ast_vasprintf(ret, fmt, ap) \ 281 __ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__) 290 #define ast_alloca(size) __builtin_alloca(size) 292 #if !defined(ast_strdupa) && defined(__GNUC__) 300 #define ast_strdupa(s) \ 303 const char *__old = (s); \ 304 size_t __len = strlen(__old) + 1; \ 305 char *__new = __builtin_alloca(__len); \ 306 memcpy (__new, __old, __len); \ 312 #error "NEVER INCLUDE astmm.h DIRECTLY!!" void ast_std_free(void *ptr)
void * __ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc
void * ast_std_malloc(size_t size) attribute_malloc
void * __ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc
char * __ast_repl_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc
void __ast_free(void *ptr, const char *file, int lineno, const char *func)
char * __ast_strdup(const char *s, const char *file, int lineno, const char *func) attribute_malloc
void * ast_std_realloc(void *ptr, size_t size)
void * __ast_repl_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
void ast_free_ptr(void *ptr)
free() wrapper
int __ast_vasprintf(char **strp, const char *format, va_list ap, 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) attribute_malloc
int __ast_repl_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format,...)
void * __ast_repl_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc
void * __ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
void * ast_std_calloc(size_t nmemb, size_t size) attribute_malloc
int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, 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) attribute_malloc
char * __ast_repl_strdup(const char *s, const char *file, int lineno, const char *func) attribute_malloc
static snd_pcm_format_t format
int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format,...)
void * __ast_malloc(size_t size, const char *file, int lineno, const char *func) attribute_malloc