00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef NO_AST_MM
00024 #ifndef _ASTERISK_ASTMM_H
00025 #define _ASTERISK_ASTMM_H
00026
00027 #define __AST_DEBUG_MALLOC
00028
00029
00030 #include <sys/types.h>
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <stdio.h>
00034
00035
00036 #undef malloc
00037 #undef calloc
00038 #undef realloc
00039 #undef strdup
00040 #undef strndup
00041 #undef vasprintf
00042
00043 void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
00044 void *__ast_malloc(size_t size, const char *file, int lineno, const char *func);
00045 void __ast_free(void *ptr, const char *file, int lineno, const char *func);
00046 void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
00047 char *__ast_strdup(const char *s, const char *file, int lineno, const char *func);
00048 char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
00049 int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func);
00050
00051 void __ast_mm_init(void);
00052
00053
00054
00055 #define calloc(a,b) \
00056 __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00057
00058 #define malloc(a) \
00059 __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00060
00061 #define free(a) \
00062 __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00063
00064 #define realloc(a,b) \
00065 __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00066
00067 #define strdup(a) \
00068 __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00069
00070 #define strndup(a,b) \
00071 __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00072
00073 #define vasprintf(a,b,c) \
00074 __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00075
00076 #else
00077 #error "NEVER INCLUDE astmm.h DIRECTLY!!"
00078 #endif
00079 #endif