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