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