00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00031 #ifndef _ASTERISK_ASTMM_H
00032 #define _ASTERISK_ASTMM_H
00033
00034 #ifndef STANDALONE
00035
00036 #define __AST_DEBUG_MALLOC
00037
00038 #include "asterisk.h"
00039
00040
00041 #include <sys/types.h>
00042 #include <stdlib.h>
00043 #include <string.h>
00044 #include <stdio.h>
00045 #include <stdarg.h>
00046
00047
00048 #undef malloc
00049 #undef calloc
00050 #undef realloc
00051 #undef strdup
00052 #undef strndup
00053 #undef asprintf
00054 #undef vasprintf
00055 #undef free
00056
00057 void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
00058 void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
00059 void *__ast_malloc(size_t size, const char *file, int lineno, const char *func);
00060 void __ast_free(void *ptr, const char *file, int lineno, const char *func);
00061 void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
00062 char *__ast_strdup(const char *s, const char *file, int lineno, const char *func);
00063 char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
00064 int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
00065 __attribute__((format(printf, 5, 6)));
00066 int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
00067 __attribute__((format(printf, 2, 0)));
00068 void __ast_mm_init(void);
00069
00070
00071
00072 #define calloc(a,b) \
00073 __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00074
00075 #define ast_calloc(a,b) \
00076 __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00077
00078 #define ast_calloc_cache(a,b) \
00079 __ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00080
00081 #define malloc(a) \
00082 __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00083
00084 #define ast_malloc(a) \
00085 __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00086
00087 #define free(a) \
00088 __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00089
00090 #define ast_free(a) \
00091 __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00092
00093 #define realloc(a,b) \
00094 __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00095
00096 #define ast_realloc(a,b) \
00097 __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00098
00099 #define strdup(a) \
00100 __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00101
00102 #define ast_strdup(a) \
00103 __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00104
00105 #define strndup(a,b) \
00106 __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00107
00108 #define ast_strndup(a,b) \
00109 __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00110
00111 #define asprintf(a, b, c...) \
00112 __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
00113
00114 #define ast_asprintf(a, b, c...) \
00115 __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
00116
00117 #define vasprintf(a,b,c) \
00118 __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00119
00120 #define ast_vasprintf(a,b,c) \
00121 __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00122
00123 #endif
00124
00125 #else
00126 #error "NEVER INCLUDE astmm.h DIRECTLY!!"
00127 #endif
00128
00129 #ifdef __cplusplus
00130 }
00131 #endif