Thu Oct 11 06:42:01 2012

Asterisk developer's documentation


astmm.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2006, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * \brief Asterisk memory usage debugging
00021  */
00022 
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 #ifndef _ASTERISK_ASTMM_H
00029 #define _ASTERISK_ASTMM_H
00030 
00031 #define __AST_DEBUG_MALLOC
00032 
00033 #include "asterisk.h"
00034 
00035 /* Include these now to prevent them from being needed later */
00036 #include <sys/types.h>
00037 #include <stdlib.h>
00038 #include <string.h>
00039 #include <stdio.h>
00040 #include <stdarg.h>
00041 
00042 /* Undefine any macros */
00043 #undef malloc
00044 #undef calloc
00045 #undef realloc
00046 #undef strdup
00047 #undef strndup
00048 #undef asprintf
00049 #undef vasprintf
00050 #undef free
00051 
00052 void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
00053 void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
00054 void *__ast_malloc(size_t size, const char *file, int lineno, const char *func);
00055 void __ast_free(void *ptr, const char *file, int lineno, const char *func);
00056 void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
00057 char *__ast_strdup(const char *s, const char *file, int lineno, const char *func);
00058 char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
00059 int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) __attribute__((format(printf, 5, 6)));
00060 int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) __attribute__((format(printf, 2, 0)));
00061 
00062 void __ast_mm_init(void);
00063 
00064 
00065 /* Provide our own definitions */
00066 #define calloc(a,b) \
00067    __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00068 
00069 #define ast_calloc(a,b) \
00070    __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00071 
00072 #define ast_calloc_cache(a,b) \
00073    __ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00074 
00075 #define malloc(a) \
00076    __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00077 
00078 #define ast_malloc(a) \
00079    __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00080 
00081 #define free(a) \
00082    __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00083 
00084 #define ast_free(a) \
00085    __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00086 
00087 #define realloc(a,b) \
00088    __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00089 
00090 #define ast_realloc(a,b) \
00091    __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00092 
00093 #define strdup(a) \
00094    __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00095 
00096 #define ast_strdup(a) \
00097    __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00098 
00099 #define strndup(a,b) \
00100    __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00101 
00102 #define ast_strndup(a,b) \
00103    __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00104 
00105 #define asprintf(a, b, c...) \
00106    __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
00107 
00108 #define ast_asprintf(a, b, c...) \
00109    __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
00110 
00111 #define vasprintf(a,b,c) \
00112    __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00113 
00114 #define ast_vasprintf(a,b,c) \
00115    __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00116 
00117 #ifdef __cplusplus
00118 }
00119 #endif
00120 
00121 #else
00122 #error "NEVER INCLUDE astmm.h DIRECTLY!!"
00123 #endif /* _ASTERISK_ASTMM_H */

Generated on Thu Oct 11 06:42:01 2012 for Asterisk - the Open Source PBX by  doxygen 1.5.6