|
|
@ -684,41 +684,6 @@ int ast_channel_trylock(struct ast_channel *chan);
|
|
|
|
#define ast_free free
|
|
|
|
#define ast_free free
|
|
|
|
#define ast_free_ptr free
|
|
|
|
#define ast_free_ptr free
|
|
|
|
|
|
|
|
|
|
|
|
#define MALLOC_FAILURE_MSG \
|
|
|
|
|
|
|
|
ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief A wrapper for malloc()
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* ast_malloc() is a wrapper for malloc() that will generate an Asterisk log
|
|
|
|
|
|
|
|
* message in the case that the allocation fails.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* The argument and return value are the same as malloc()
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define ast_malloc(len) \
|
|
|
|
|
|
|
|
_ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ast_calloc(num, len) \
|
|
|
|
|
|
|
|
_ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ast_calloc_cache(num, len) \
|
|
|
|
|
|
|
|
_ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ast_realloc(p, len) \
|
|
|
|
|
|
|
|
_ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ast_strdup(str) \
|
|
|
|
|
|
|
|
_ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ast_strndup(str, len) \
|
|
|
|
|
|
|
|
_ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ast_asprintf(ret, fmt, ...) \
|
|
|
|
|
|
|
|
_ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ast_vasprintf(ret, fmt, ap) \
|
|
|
|
|
|
|
|
_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct ast_flags { /* stolen from utils.h */
|
|
|
|
struct ast_flags { /* stolen from utils.h */
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned int flags;
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -743,6 +708,7 @@ struct ast_flags { /* stolen from utils.h */
|
|
|
|
|
|
|
|
|
|
|
|
#define MALLOC_FAILURE_MSG \
|
|
|
|
#define MALLOC_FAILURE_MSG \
|
|
|
|
ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
|
|
|
|
ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief A wrapper for malloc()
|
|
|
|
* \brief A wrapper for malloc()
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -752,10 +718,10 @@ struct ast_flags { /* stolen from utils.h */
|
|
|
|
* The argument and return value are the same as malloc()
|
|
|
|
* The argument and return value are the same as malloc()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_malloc(len) \
|
|
|
|
#define ast_malloc(len) \
|
|
|
|
_ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
__ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
AST_INLINE_API(
|
|
|
|
AST_INLINE_API(
|
|
|
|
void * attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, const char *func),
|
|
|
|
void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, const char *func),
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
void *p;
|
|
|
|
|
|
|
|
|
|
|
@ -775,10 +741,10 @@ void * attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, co
|
|
|
|
* The arguments and return value are the same as calloc()
|
|
|
|
* The arguments and return value are the same as calloc()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_calloc(num, len) \
|
|
|
|
#define ast_calloc(num, len) \
|
|
|
|
_ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
__ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
AST_INLINE_API(
|
|
|
|
AST_INLINE_API(
|
|
|
|
void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func),
|
|
|
|
void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func),
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void *p;
|
|
|
|
void *p;
|
|
|
|
|
|
|
|
|
|
|
@ -800,7 +766,7 @@ void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, in
|
|
|
|
* The arguments and return value are the same as calloc()
|
|
|
|
* The arguments and return value are the same as calloc()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_calloc_cache(num, len) \
|
|
|
|
#define ast_calloc_cache(num, len) \
|
|
|
|
_ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
__ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief A wrapper for realloc()
|
|
|
|
* \brief A wrapper for realloc()
|
|
|
@ -811,10 +777,10 @@ void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, in
|
|
|
|
* The arguments and return value are the same as realloc()
|
|
|
|
* The arguments and return value are the same as realloc()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_realloc(p, len) \
|
|
|
|
#define ast_realloc(p, len) \
|
|
|
|
_ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
__ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
AST_INLINE_API(
|
|
|
|
AST_INLINE_API(
|
|
|
|
void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
|
|
|
|
void * attribute_malloc __ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func),
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void *newp;
|
|
|
|
void *newp;
|
|
|
|
|
|
|
|
|
|
|
@ -838,10 +804,10 @@ void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int
|
|
|
|
* The argument and return value are the same as strdup()
|
|
|
|
* The argument and return value are the same as strdup()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_strdup(str) \
|
|
|
|
#define ast_strdup(str) \
|
|
|
|
_ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
__ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
AST_INLINE_API(
|
|
|
|
AST_INLINE_API(
|
|
|
|
char * attribute_malloc _ast_strdup(const char *str, const char *file, int lineno, const char *func),
|
|
|
|
char * attribute_malloc __ast_strdup(const char *str, const char *file, int lineno, const char *func),
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *newstr = NULL;
|
|
|
|
char *newstr = NULL;
|
|
|
|
|
|
|
|
|
|
|
@ -867,10 +833,10 @@ char * attribute_malloc _ast_strdup(const char *str, const char *file, int linen
|
|
|
|
* The arguments and return value are the same as strndup()
|
|
|
|
* The arguments and return value are the same as strndup()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_strndup(str, len) \
|
|
|
|
#define ast_strndup(str, len) \
|
|
|
|
_ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
__ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
AST_INLINE_API(
|
|
|
|
AST_INLINE_API(
|
|
|
|
char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func),
|
|
|
|
char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func),
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *newstr = NULL;
|
|
|
|
char *newstr = NULL;
|
|
|
|
|
|
|
|
|
|
|
@ -892,11 +858,11 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi
|
|
|
|
* The arguments and return value are the same as asprintf()
|
|
|
|
* The arguments and return value are the same as asprintf()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_asprintf(ret, fmt, ...) \
|
|
|
|
#define ast_asprintf(ret, fmt, ...) \
|
|
|
|
_ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
|
|
|
|
__ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
|
|
AST_INLINE_API(
|
|
|
|
AST_INLINE_API(
|
|
|
|
__attribute__((format(printf, 5, 6)))
|
|
|
|
__attribute__((format(printf, 5, 6)))
|
|
|
|
int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...),
|
|
|
|
int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...),
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
int res;
|
|
|
|
va_list ap;
|
|
|
|
va_list ap;
|
|
|
@ -919,11 +885,11 @@ int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, co
|
|
|
|
* The arguments and return value are the same as vasprintf()
|
|
|
|
* The arguments and return value are the same as vasprintf()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#define ast_vasprintf(ret, fmt, ap) \
|
|
|
|
#define ast_vasprintf(ret, fmt, ap) \
|
|
|
|
_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
|
|
|
|
__ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
|
|
|
|
|
|
|
|
|
|
AST_INLINE_API(
|
|
|
|
AST_INLINE_API(
|
|
|
|
__attribute__((format(printf, 5, 0)))
|
|
|
|
__attribute__((format(printf, 2, 0)))
|
|
|
|
int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap),
|
|
|
|
int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, int lineno, const char *func),
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
|
|