Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

astmm.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  *
00004  * Asterisk debugging
00005  * 
00006  * Copyright (C) 2002, Mark Spencer
00007  *
00008  * Mark Spencer <markster@linux-support.net>
00009  *
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License
00012  */
00013 
00014 #ifndef NO_AST_MM
00015 #ifndef _ASTMM_H
00016 #define _ASTMM_H
00017 
00018 #define __AST_DEBUG_MALLOC
00019 
00020 /* Include these now to prevent them from being needed later */
00021 #include <sys/types.h>
00022 #include <stdlib.h>
00023 #include <string.h>
00024 
00025 /* Undefine any macros */
00026 #undef malloc
00027 #undef calloc
00028 #undef realloc
00029 #undef strdup
00030 #undef strndup
00031 
00032 void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
00033 void *__ast_malloc(size_t size, const char *file, int lineno, const char *func);
00034 void __ast_free(void *ptr, const char *file, int lineno, const char *func);
00035 void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
00036 char *__ast_strdup(const char *s, const char *file, int lineno, const char *func);
00037 char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
00038 
00039 void __ast_mm_init(void);
00040 
00041 
00042 /* Provide our own definitions */
00043 #define calloc(a,b) \
00044    __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00045 
00046 #define malloc(a) \
00047    __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00048 
00049 #define free(a) \
00050    __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00051 
00052 #define realloc(a,b) \
00053    __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00054 
00055 #define strdup(a) \
00056    __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00057 
00058 #define strndup(a,b) \
00059    __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
00060 
00061 #else
00062 #error "NEVER INCLUDE astmm.h DIRECTLY!!"
00063 #endif
00064 #endif

Generated on Fri Oct 31 07:05:05 2003 for Asterisk by doxygen 1.3.4