mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
Fix naming mismatch of allocator functions.
Allocator functions that take file/line/func parameters are prefixed with single-underscore when MALLOC_DEBUG is not defined, double-underscore when it is defined. This change updates all allocators that accept file/line/func to have the same prototype in either ABI mode. The parameter order of __ast_vasprintf and __ast_asprintf in utils.h have been changed to match that of astmm.h. End-use allocator macro's have been removed from astmm.h and moved to an unconditional part of utils.h. Change-Id: I823bb6ce2b5675b3a4735948f10a3b420e9a023a
This commit is contained in:
@@ -174,35 +174,11 @@ void __ast_mm_init_phase_2(void);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Provide our own definitions */
|
/* Provide our own definition for ast_free */
|
||||||
|
|
||||||
#define ast_calloc(a,b) \
|
|
||||||
__ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#define ast_calloc_cache(a,b) \
|
|
||||||
__ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#define ast_malloc(a) \
|
|
||||||
__ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#define ast_free(a) \
|
#define ast_free(a) \
|
||||||
__ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
__ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
#define ast_realloc(a,b) \
|
|
||||||
__ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#define ast_strdup(a) \
|
|
||||||
__ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#define ast_strndup(a,b) \
|
|
||||||
__ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#define ast_asprintf(a, b, c...) \
|
|
||||||
__ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
|
|
||||||
|
|
||||||
#define ast_vasprintf(a,b,c) \
|
|
||||||
__ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#endif /* !STANDALONE */
|
#endif /* !STANDALONE */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@@ -533,19 +533,8 @@ long int ast_random(void);
|
|||||||
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)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
|
||||||
* \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__)
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -559,19 +548,8 @@ void * attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, co
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A wrapper for calloc()
|
|
||||||
*
|
|
||||||
* ast_calloc() is a wrapper for calloc() that will generate an Asterisk log
|
|
||||||
* message in the case that the allocation fails.
|
|
||||||
*
|
|
||||||
* The arguments and return value are the same as calloc()
|
|
||||||
*/
|
|
||||||
#define ast_calloc(num, len) \
|
|
||||||
_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;
|
||||||
|
|
||||||
@@ -585,32 +563,8 @@ void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, in
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A wrapper for calloc() for use in cache pools
|
|
||||||
*
|
|
||||||
* ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log
|
|
||||||
* message in the case that the allocation fails. When memory debugging is in use,
|
|
||||||
* the memory allocated by this function will be marked as 'cache' so it can be
|
|
||||||
* distinguished from normal memory allocations.
|
|
||||||
*
|
|
||||||
* The arguments and return value are the same as calloc()
|
|
||||||
*/
|
|
||||||
#define ast_calloc_cache(num, len) \
|
|
||||||
_ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A wrapper for realloc()
|
|
||||||
*
|
|
||||||
* ast_realloc() is a wrapper for realloc() that will generate an Asterisk log
|
|
||||||
* message in the case that the allocation fails.
|
|
||||||
*
|
|
||||||
* The arguments and return value are the same as realloc()
|
|
||||||
*/
|
|
||||||
#define ast_realloc(p, len) \
|
|
||||||
_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;
|
||||||
|
|
||||||
@@ -624,23 +578,8 @@ void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A wrapper for strdup()
|
|
||||||
*
|
|
||||||
* ast_strdup() is a wrapper for strdup() that will generate an Asterisk log
|
|
||||||
* message in the case that the allocation fails.
|
|
||||||
*
|
|
||||||
* ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL
|
|
||||||
* argument is provided, ast_strdup will return NULL without generating any
|
|
||||||
* kind of error log message.
|
|
||||||
*
|
|
||||||
* The argument and return value are the same as strdup()
|
|
||||||
*/
|
|
||||||
#define ast_strdup(str) \
|
|
||||||
_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;
|
||||||
|
|
||||||
@@ -656,23 +595,8 @@ char * attribute_malloc _ast_strdup(const char *str, const char *file, int linen
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A wrapper for strndup()
|
|
||||||
*
|
|
||||||
* ast_strndup() is a wrapper for strndup() that will generate an Asterisk log
|
|
||||||
* message in the case that the allocation fails.
|
|
||||||
*
|
|
||||||
* ast_strndup(), unlike strndup(), can safely accept a NULL argument for the
|
|
||||||
* string to duplicate. If a NULL argument is provided, ast_strdup will return
|
|
||||||
* NULL without generating any kind of error log message.
|
|
||||||
*
|
|
||||||
* The arguments and return value are the same as strndup()
|
|
||||||
*/
|
|
||||||
#define ast_strndup(str, len) \
|
|
||||||
_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;
|
||||||
|
|
||||||
@@ -688,34 +612,12 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A wrapper for asprintf()
|
|
||||||
*
|
|
||||||
* ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log
|
|
||||||
* message in the case that the allocation fails.
|
|
||||||
*
|
|
||||||
* The arguments and return value are the same as asprintf()
|
|
||||||
*/
|
|
||||||
#define ast_asprintf(ret, fmt, ...) \
|
|
||||||
_ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__)
|
|
||||||
|
|
||||||
int __attribute__((format(printf, 5, 6)))
|
int __attribute__((format(printf, 5, 6)))
|
||||||
_ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...);
|
__ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...);
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief A wrapper for vasprintf()
|
|
||||||
*
|
|
||||||
* ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log
|
|
||||||
* message in the case that the allocation fails.
|
|
||||||
*
|
|
||||||
* The arguments and return value are the same as vasprintf()
|
|
||||||
*/
|
|
||||||
#define ast_vasprintf(ret, fmt, ap) \
|
|
||||||
_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -731,6 +633,104 @@ int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, c
|
|||||||
|
|
||||||
#endif /* AST_DEBUG_MALLOC */
|
#endif /* AST_DEBUG_MALLOC */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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__)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A wrapper for calloc()
|
||||||
|
*
|
||||||
|
* ast_calloc() is a wrapper for calloc() that will generate an Asterisk log
|
||||||
|
* message in the case that the allocation fails.
|
||||||
|
*
|
||||||
|
* The arguments and return value are the same as calloc()
|
||||||
|
*/
|
||||||
|
#define ast_calloc(num, len) \
|
||||||
|
__ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A wrapper for calloc() for use in cache pools
|
||||||
|
*
|
||||||
|
* ast_calloc_cache() is a wrapper for calloc() that will generate an Asterisk log
|
||||||
|
* message in the case that the allocation fails. When memory debugging is in use,
|
||||||
|
* the memory allocated by this function will be marked as 'cache' so it can be
|
||||||
|
* distinguished from normal memory allocations.
|
||||||
|
*
|
||||||
|
* The arguments and return value are the same as calloc()
|
||||||
|
*/
|
||||||
|
#define ast_calloc_cache(num, len) \
|
||||||
|
__ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A wrapper for realloc()
|
||||||
|
*
|
||||||
|
* ast_realloc() is a wrapper for realloc() that will generate an Asterisk log
|
||||||
|
* message in the case that the allocation fails.
|
||||||
|
*
|
||||||
|
* The arguments and return value are the same as realloc()
|
||||||
|
*/
|
||||||
|
#define ast_realloc(p, len) \
|
||||||
|
__ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A wrapper for strdup()
|
||||||
|
*
|
||||||
|
* ast_strdup() is a wrapper for strdup() that will generate an Asterisk log
|
||||||
|
* message in the case that the allocation fails.
|
||||||
|
*
|
||||||
|
* ast_strdup(), unlike strdup(), can safely accept a NULL argument. If a NULL
|
||||||
|
* argument is provided, ast_strdup will return NULL without generating any
|
||||||
|
* kind of error log message.
|
||||||
|
*
|
||||||
|
* The argument and return value are the same as strdup()
|
||||||
|
*/
|
||||||
|
#define ast_strdup(str) \
|
||||||
|
__ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A wrapper for strndup()
|
||||||
|
*
|
||||||
|
* ast_strndup() is a wrapper for strndup() that will generate an Asterisk log
|
||||||
|
* message in the case that the allocation fails.
|
||||||
|
*
|
||||||
|
* ast_strndup(), unlike strndup(), can safely accept a NULL argument for the
|
||||||
|
* string to duplicate. If a NULL argument is provided, ast_strdup will return
|
||||||
|
* NULL without generating any kind of error log message.
|
||||||
|
*
|
||||||
|
* The arguments and return value are the same as strndup()
|
||||||
|
*/
|
||||||
|
#define ast_strndup(str, len) \
|
||||||
|
__ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A wrapper for asprintf()
|
||||||
|
*
|
||||||
|
* ast_asprintf() is a wrapper for asprintf() that will generate an Asterisk log
|
||||||
|
* message in the case that the allocation fails.
|
||||||
|
*
|
||||||
|
* The arguments and return value are the same as asprintf()
|
||||||
|
*/
|
||||||
|
#define ast_asprintf(ret, fmt, ...) \
|
||||||
|
__ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A wrapper for vasprintf()
|
||||||
|
*
|
||||||
|
* ast_vasprintf() is a wrapper for vasprintf() that will generate an Asterisk log
|
||||||
|
* message in the case that the allocation fails.
|
||||||
|
*
|
||||||
|
* The arguments and return value are the same as vasprintf()
|
||||||
|
*/
|
||||||
|
#define ast_vasprintf(ret, fmt, ap) \
|
||||||
|
__ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief call __builtin_alloca to ensure we get gcc builtin semantics
|
\brief call __builtin_alloca to ensure we get gcc builtin semantics
|
||||||
\param size The size of the buffer we want allocated
|
\param size The size of the buffer we want allocated
|
||||||
|
@@ -591,11 +591,7 @@ void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned in
|
|||||||
|
|
||||||
switch (options & AO2_ALLOC_OPT_LOCK_MASK) {
|
switch (options & AO2_ALLOC_OPT_LOCK_MASK) {
|
||||||
case AO2_ALLOC_OPT_LOCK_MUTEX:
|
case AO2_ALLOC_OPT_LOCK_MUTEX:
|
||||||
#if defined(__AST_DEBUG_MALLOC)
|
|
||||||
obj_mutex = __ast_calloc(1, sizeof(*obj_mutex) + data_size, file, line, func);
|
obj_mutex = __ast_calloc(1, sizeof(*obj_mutex) + data_size, file, line, func);
|
||||||
#else
|
|
||||||
obj_mutex = ast_calloc(1, sizeof(*obj_mutex) + data_size);
|
|
||||||
#endif
|
|
||||||
if (obj_mutex == NULL) {
|
if (obj_mutex == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -604,11 +600,7 @@ void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned in
|
|||||||
obj = (struct astobj2 *) &obj_mutex->priv_data;
|
obj = (struct astobj2 *) &obj_mutex->priv_data;
|
||||||
break;
|
break;
|
||||||
case AO2_ALLOC_OPT_LOCK_RWLOCK:
|
case AO2_ALLOC_OPT_LOCK_RWLOCK:
|
||||||
#if defined(__AST_DEBUG_MALLOC)
|
|
||||||
obj_rwlock = __ast_calloc(1, sizeof(*obj_rwlock) + data_size, file, line, func);
|
obj_rwlock = __ast_calloc(1, sizeof(*obj_rwlock) + data_size, file, line, func);
|
||||||
#else
|
|
||||||
obj_rwlock = ast_calloc(1, sizeof(*obj_rwlock) + data_size);
|
|
||||||
#endif
|
|
||||||
if (obj_rwlock == NULL) {
|
if (obj_rwlock == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -617,11 +609,7 @@ void *__ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned in
|
|||||||
obj = (struct astobj2 *) &obj_rwlock->priv_data;
|
obj = (struct astobj2 *) &obj_rwlock->priv_data;
|
||||||
break;
|
break;
|
||||||
case AO2_ALLOC_OPT_LOCK_NOLOCK:
|
case AO2_ALLOC_OPT_LOCK_NOLOCK:
|
||||||
#if defined(__AST_DEBUG_MALLOC)
|
|
||||||
obj = __ast_calloc(1, sizeof(*obj) + data_size, file, line, func);
|
obj = __ast_calloc(1, sizeof(*obj) + data_size, file, line, func);
|
||||||
#else
|
|
||||||
obj = ast_calloc(1, sizeof(*obj) + data_size);
|
|
||||||
#endif
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -682,11 +682,7 @@ void ast_cc_default_config_params(struct ast_cc_config_params *params)
|
|||||||
|
|
||||||
struct ast_cc_config_params *__ast_cc_config_params_init(const char *file, int line, const char *function)
|
struct ast_cc_config_params *__ast_cc_config_params_init(const char *file, int line, const char *function)
|
||||||
{
|
{
|
||||||
#if defined(__AST_DEBUG_MALLOC)
|
|
||||||
struct ast_cc_config_params *params = __ast_malloc(sizeof(*params), file, line, function);
|
struct ast_cc_config_params *params = __ast_malloc(sizeof(*params), file, line, function);
|
||||||
#else
|
|
||||||
struct ast_cc_config_params *params = ast_malloc(sizeof(*params));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!params) {
|
if (!params) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -47,15 +47,9 @@ struct ast_datastore *__ast_datastore_alloc(const struct ast_datastore_info *inf
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__AST_DEBUG_MALLOC)
|
|
||||||
if (!(datastore = __ast_calloc(1, sizeof(*datastore), file, line, function))) {
|
if (!(datastore = __ast_calloc(1, sizeof(*datastore), file, line, function))) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (!(datastore = ast_calloc(1, sizeof(*datastore)))) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
datastore->info = info;
|
datastore->info = info;
|
||||||
|
|
||||||
|
@@ -60,11 +60,7 @@ static size_t optimal_alloc_size(size_t size)
|
|||||||
static void *calloc_wrapper(unsigned int num_structs, size_t struct_size,
|
static void *calloc_wrapper(unsigned int num_structs, size_t struct_size,
|
||||||
const char *file, int lineno, const char *func)
|
const char *file, int lineno, const char *func)
|
||||||
{
|
{
|
||||||
#if defined(__AST_DEBUG_MALLOC)
|
|
||||||
return __ast_calloc(num_structs, struct_size, file, lineno, func);
|
return __ast_calloc(num_structs, struct_size, file, lineno, func);
|
||||||
#else
|
|
||||||
return ast_calloc(num_structs, struct_size);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief add a new block to the pool.
|
/*! \brief add a new block to the pool.
|
||||||
|
@@ -2369,7 +2369,7 @@ int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __AST_DEBUG_MALLOC
|
#ifndef __AST_DEBUG_MALLOC
|
||||||
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;
|
||||||
|
@@ -42,9 +42,9 @@ enum ast_lock_type {
|
|||||||
#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);
|
||||||
|
|
||||||
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 * 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;
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user