2003-04-28 19:58:43 +00:00
|
|
|
/*
|
2005-08-30 18:32:10 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2003-04-28 19:58:43 +00:00
|
|
|
*
|
2006-01-04 21:54:09 +00:00
|
|
|
* Copyright (C) 1999 - 2006, Digium, Inc.
|
2003-04-28 19:58:43 +00:00
|
|
|
*
|
2005-08-30 18:32:10 +00:00
|
|
|
* Mark Spencer <markster@digium.com>
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
2003-04-28 19:58:43 +00:00
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
2005-08-30 18:32:10 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
|
|
|
* \brief Asterisk memory usage debugging
|
2010-01-12 07:48:16 +00:00
|
|
|
* This file provides headers for MALLOC_DEBUG, a define used for tracking down
|
2010-06-08 14:38:18 +00:00
|
|
|
* memory leaks. It should never be \#included directly; always use the
|
2010-01-12 07:48:16 +00:00
|
|
|
* MALLOC_DEBUG definition in menuselect to activate those functions.
|
2003-04-28 19:58:43 +00:00
|
|
|
*/
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-08-30 18:32:10 +00:00
|
|
|
#ifndef _ASTERISK_ASTMM_H
|
|
|
|
#define _ASTERISK_ASTMM_H
|
2003-04-28 19:58:43 +00:00
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#ifndef STANDALONE
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
#define __AST_DEBUG_MALLOC
|
|
|
|
|
2006-06-07 19:53:03 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
2008-09-27 16:10:33 +00:00
|
|
|
/* Include these now to prevent them from being needed later */
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
/* Undefine any macros */
|
|
|
|
#undef malloc
|
|
|
|
#undef calloc
|
|
|
|
#undef realloc
|
|
|
|
#undef strdup
|
|
|
|
#undef strndup
|
2006-01-04 21:54:09 +00:00
|
|
|
#undef asprintf
|
2004-01-14 06:35:01 +00:00
|
|
|
#undef vasprintf
|
2009-03-11 04:06:44 +00:00
|
|
|
#undef free
|
2003-04-28 19:58:43 +00:00
|
|
|
|
2013-08-23 18:07:40 +00:00
|
|
|
void *ast_std_malloc(size_t size);
|
|
|
|
void *ast_std_calloc(size_t nmemb, size_t size);
|
|
|
|
void *ast_std_realloc(void *ptr, size_t size);
|
|
|
|
void ast_std_free(void *ptr);
|
|
|
|
void ast_free_ptr(void *ptr);
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
|
2006-12-27 18:33:44 +00:00
|
|
|
void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
|
2003-04-28 19:58:43 +00:00
|
|
|
void *__ast_malloc(size_t size, const char *file, int lineno, const char *func);
|
|
|
|
void __ast_free(void *ptr, const char *file, int lineno, const char *func);
|
|
|
|
void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func);
|
|
|
|
char *__ast_strdup(const char *s, const char *file, int lineno, const char *func);
|
|
|
|
char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func);
|
2008-03-18 17:00:53 +00:00
|
|
|
int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
|
2008-11-29 17:57:39 +00:00
|
|
|
__attribute__((format(printf, 5, 6)));
|
2008-03-18 17:00:53 +00:00
|
|
|
int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
|
2008-11-29 17:57:39 +00:00
|
|
|
__attribute__((format(printf, 2, 0)));
|
2012-11-08 17:38:31 +00:00
|
|
|
void __ast_mm_init_phase_1(void);
|
|
|
|
void __ast_mm_init_phase_2(void);
|
2003-04-28 19:58:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Provide our own definitions */
|
|
|
|
#define calloc(a,b) \
|
|
|
|
__ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#define ast_calloc(a,b) \
|
|
|
|
__ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2006-12-27 18:33:44 +00:00
|
|
|
#define ast_calloc_cache(a,b) \
|
|
|
|
__ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
#define malloc(a) \
|
|
|
|
__ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#define ast_malloc(a) \
|
|
|
|
__ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
#define free(a) \
|
|
|
|
__ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#define ast_free(a) \
|
|
|
|
__ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
#define realloc(a,b) \
|
|
|
|
__ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#define ast_realloc(a,b) \
|
|
|
|
__ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
#define strdup(a) \
|
|
|
|
__ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#define ast_strdup(a) \
|
|
|
|
__ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
#define strndup(a,b) \
|
|
|
|
__ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#define ast_strndup(a,b) \
|
|
|
|
__ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2006-01-04 21:54:09 +00:00
|
|
|
#define asprintf(a, b, c...) \
|
|
|
|
__ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#define ast_asprintf(a, b, c...) \
|
|
|
|
__ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
|
|
|
|
|
2004-01-14 06:35:01 +00:00
|
|
|
#define vasprintf(a,b,c) \
|
|
|
|
__ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
2009-03-11 04:06:44 +00:00
|
|
|
#define ast_vasprintf(a,b,c) \
|
|
|
|
__ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
#endif /* !STANDALONE */
|
|
|
|
|
2003-04-28 19:58:43 +00:00
|
|
|
#else
|
|
|
|
#error "NEVER INCLUDE astmm.h DIRECTLY!!"
|
2005-08-30 18:32:10 +00:00
|
|
|
#endif /* _ASTERISK_ASTMM_H */
|
2009-03-11 04:06:44 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|