![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
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 #ifndef _ASTERISK_ASTMM_H 00024 #define _ASTERISK_ASTMM_H 00025 00026 #define __AST_DEBUG_MALLOC 00027 00028 #include "asterisk.h" 00029 00030 /* Include these now to prevent them from being needed later */ 00031 #include <sys/types.h> 00032 #include <stdlib.h> 00033 #include <string.h> 00034 #include <stdio.h> 00035 #include <stdarg.h> 00036 00037 /* Undefine any macros */ 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 /* Provide our own definitions */ 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 /* _ASTERISK_ASTMM_H */