Asterisk - The Open Source Telephony Project GIT-master-3dae2cf
|
Asterisk memory management routines. More...
Go to the source code of this file.
Macros | |
#define | _ASTERISK_ASTMM_H |
#define | asprintf(a, b, c...) Do_not_use_asprintf__use_ast_asprintf->fail(a, b, c) |
#define | ast_alloca(size) __builtin_alloca(size) |
call __builtin_alloca to ensure we get gcc builtin semantics More... | |
#define | ast_asprintf(ret, fmt, ...) __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__) |
A wrapper for asprintf() More... | |
#define | ast_calloc(num, len) __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for calloc() More... | |
#define | ast_calloc_cache(num, len) __ast_calloc_cache((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for calloc() for use in cache pools. More... | |
#define | ast_free(a) __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_malloc(len) __ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for malloc() More... | |
#define | ast_realloc(p, len) __ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for realloc() More... | |
#define | ast_strdup(str) __ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for strdup() More... | |
#define | ast_strdupa(s) |
duplicate a string in memory from the stack More... | |
#define | ast_strndup(str, len) __ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for strndup() More... | |
#define | ast_vasprintf(ret, fmt, ap) __ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
A wrapper for vasprintf() More... | |
#define | ASTMM_LIBC ASTMM_BLOCK |
#define | calloc(a, b) Do_not_use_calloc__use_ast_calloc->fail(a, b) |
#define | free(a) Do_not_use_free__use_ast_free_or_ast_std_free_for_remotely_allocated_memory->fail(a) |
#define | malloc(a) Do_not_use_malloc__use_ast_malloc->fail(a) |
#define | realloc(a, b) Do_not_use_realloc__use_ast_realloc->fail(a, b) |
#define | strdup(a) Do_not_use_strdup__use_ast_strdup->fail(a) |
#define | strndup(a, b) Do_not_use_strndup__use_ast_strndup->fail(a, b) |
#define | vasprintf(a, b, c) Do_not_use_vasprintf__use_ast_vasprintf->fail(a, b, c) |
#define | ASTMM_BLOCK 0 |
ASTMM_LIBC can be defined to control the meaning of standard allocators. More... | |
#define | ASTMM_IGNORE 2 |
Standard allocators are used directly. More... | |
#define | ASTMM_REDIRECT 1 |
Redirect standard allocators to use Asterisk functions. More... | |
Functions | |
int | __ast_asprintf (const char *file, int lineno, const char *func, char **strp, const char *format,...) |
void * | __ast_calloc (size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc |
void * | __ast_calloc_cache (size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc |
void | __ast_free (void *ptr, const char *file, int lineno, const char *func) |
void * | __ast_malloc (size_t size, const char *file, int lineno, const char *func) attribute_malloc |
void * | __ast_realloc (void *ptr, size_t size, const char *file, int lineno, const char *func) |
int | __ast_repl_asprintf (const char *file, int lineno, const char *func, char **strp, const char *format,...) |
void * | __ast_repl_calloc (size_t nmemb, size_t size, const char *file, int lineno, const char *func) attribute_malloc |
void * | __ast_repl_malloc (size_t size, const char *file, int lineno, const char *func) attribute_malloc |
void * | __ast_repl_realloc (void *ptr, size_t size, const char *file, int lineno, const char *func) |
char * | __ast_repl_strdup (const char *s, const char *file, int lineno, const char *func) attribute_malloc |
char * | __ast_repl_strndup (const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc |
int | __ast_repl_vasprintf (char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) |
char * | __ast_strdup (const char *s, const char *file, int lineno, const char *func) attribute_malloc |
char * | __ast_strndup (const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc |
int | __ast_vasprintf (char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) |
void | ast_free_ptr (void *ptr) |
free() wrapper More... | |
void * | ast_std_calloc (size_t nmemb, size_t size) attribute_malloc |
void | ast_std_free (void *ptr) |
void * | ast_std_malloc (size_t size) attribute_malloc |
void * | ast_std_realloc (void *ptr, size_t size) |
Asterisk memory management routines.
This file should never be #included directly, it is included by asterisk.h.
Definition in file astmm.h.
#define ast_alloca | ( | size | ) | __builtin_alloca(size) |
#define ast_asprintf | ( | ret, | |
fmt, | |||
... | |||
) | __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__) |
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_calloc | ( | num, | |
len | |||
) | __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define ast_calloc_cache | ( | num, | |
len | |||
) | __ast_calloc_cache((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
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_free | ( | a | ) | __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define ast_malloc | ( | len | ) | __ast_malloc((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__) |
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_strdupa | ( | s | ) |
duplicate a string in memory from the stack
s | The string to duplicate |
This macro will duplicate the given string. It returns a pointer to the stack allocated memory for the new string.
#define ast_strndup | ( | str, | |
len | |||
) | __ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
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_vasprintf | ( | ret, | |
fmt, | |||
ap | |||
) | __ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__) |
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 ASTMM_BLOCK 0 |
ASTMM_LIBC can be defined to control the meaning of standard allocators.
Produce compiler errors if standard allocators are used.
#define ASTMM_IGNORE 2 |
Standard allocators are used directly.
#define ASTMM_LIBC ASTMM_BLOCK |
#define ASTMM_REDIRECT 1 |
Redirect standard allocators to use Asterisk functions.
int __ast_asprintf | ( | const char * | file, |
int | lineno, | ||
const char * | func, | ||
char ** | strp, | ||
const char * | format, | ||
... | |||
) |
Definition at line 1680 of file astmm.c.
References __ast_repl_vasprintf(), make_ari_stubs::file, MALLOC_FAILURE_MSG, and NULL.
void * __ast_calloc | ( | size_t | nmemb, |
size_t | size, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1603 of file astmm.c.
References __ast_repl_calloc(), make_ari_stubs::file, and MALLOC_FAILURE_MSG.
Referenced by __ast_calloc_with_stringfields(), __ast_datastore_alloc(), __ast_frdup(), _ast_hashtab_create(), _ast_hashtab_dup(), _ast_hashtab_insert_immediate_bucket(), _ast_hashtab_resize(), _ast_hashtab_start_traversal(), _ast_hashtab_start_write_traversal(), _ast_heap_create(), _ast_var_assign(), _ast_variable_new(), add_string_pool(), ast_frame_header_new(), and internal_ao2_alloc().
void * __ast_calloc_cache | ( | size_t | nmemb, |
size_t | size, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1615 of file astmm.c.
References __ast_repl_calloc_cache(), make_ari_stubs::file, and MALLOC_FAILURE_MSG.
void __ast_free | ( | void * | ptr, |
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
void * __ast_malloc | ( | size_t | size, |
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1628 of file astmm.c.
References __ast_repl_malloc(), make_ari_stubs::file, and MALLOC_FAILURE_MSG.
Referenced by __ast_cc_config_params_init(), and _ast_heap_create().
void * __ast_realloc | ( | void * | ptr, |
size_t | size, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1640 of file astmm.c.
References __ast_repl_realloc(), make_ari_stubs::file, and MALLOC_FAILURE_MSG.
Referenced by grow_heap().
int __ast_repl_asprintf | ( | const char * | file, |
int | lineno, | ||
const char * | func, | ||
char ** | strp, | ||
const char * | format, | ||
... | |||
) |
Definition at line 1580 of file astmm.c.
References DEBUG_CHAOS_RETURN, and vasprintf().
void * __ast_repl_calloc | ( | size_t | nmemb, |
size_t | size, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1533 of file astmm.c.
References calloc, DEBUG_CHAOS_RETURN, and NULL.
Referenced by __ast_calloc().
void * __ast_repl_malloc | ( | size_t | size, |
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1547 of file astmm.c.
References DEBUG_CHAOS_RETURN, malloc(), and NULL.
Referenced by __ast_malloc().
void * __ast_repl_realloc | ( | void * | ptr, |
size_t | size, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1559 of file astmm.c.
References DEBUG_CHAOS_RETURN, NULL, and realloc.
Referenced by __ast_realloc().
char * __ast_repl_strdup | ( | const char * | s, |
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1566 of file astmm.c.
References DEBUG_CHAOS_RETURN, NULL, and strdup.
Referenced by __ast_strdup().
char * __ast_repl_strndup | ( | const char * | s, |
size_t | n, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1573 of file astmm.c.
References DEBUG_CHAOS_RETURN, NULL, and strndup().
Referenced by __ast_strndup().
int __ast_repl_vasprintf | ( | char ** | strp, |
const char * | format, | ||
va_list | ap, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1594 of file astmm.c.
References DEBUG_CHAOS_RETURN, and vasprintf().
Referenced by __ast_asprintf(), and __ast_vasprintf().
char * __ast_strdup | ( | const char * | s, |
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1652 of file astmm.c.
References __ast_repl_strdup(), make_ari_stubs::file, MALLOC_FAILURE_MSG, and NULL.
char * __ast_strndup | ( | const char * | s, |
size_t | n, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1666 of file astmm.c.
References __ast_repl_strndup(), make_ari_stubs::file, MALLOC_FAILURE_MSG, and NULL.
int __ast_vasprintf | ( | char ** | strp, |
const char * | format, | ||
va_list | ap, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 1701 of file astmm.c.
References __ast_repl_vasprintf(), make_ari_stubs::file, MALLOC_FAILURE_MSG, and NULL.
void ast_free_ptr | ( | void * | ptr | ) |
free() wrapper
ast_free_ptr should be used when a function pointer for free() needs to be passed as the argument to a function. Otherwise, astmm will cause seg faults.
Definition at line 1739 of file astmm.c.
References ast_free.
Referenced by add_extension(), add_extensions(), add_to_regcontext(), app_create(), ast_hint_presence_state(), ast_merge_contexts_and_delete(), ast_rtp_prop_set(), ast_rtp_read(), ast_sip_persistent_endpoint_update_state(), AST_TEST_DEFINE(), attended_transfer_to_ami(), blind_transfer_to_ami(), confbridge_exec(), context_merge(), control_move_cleanup(), device_state_cb(), dynamic_dtmf_hook_add(), extension_state_add_destroy(), handle_cli_dialplan_add_extension(), internal_extension_state_extended(), manager_dialplan_extension_add(), parking_add_extension(), parking_duration_callback(), pbx_load_config(), pbx_load_users(), pjsip_acf_dial_contacts_read(), refer_on_tx_request(), register_peer_exten(), sla_build_station(), sla_build_trunk(), sorcery_astdb_retrieve_id(), stasis_app_control_add_role(), stasis_app_control_continue(), stasis_app_control_dtmf(), stasis_app_control_moh_start(), stasis_app_control_move(), stasis_app_control_mute(), stasis_app_control_redirect(), stasis_app_control_unmute(), and transmit_info_dtmf().
void * ast_std_calloc | ( | size_t | nmemb, |
size_t | size | ||
) |
void ast_std_free | ( | void * | ptr | ) |
Definition at line 1734 of file astmm.c.
References free().
Referenced by action_filter(), as_check_common_config(), ast_ari_get_docs(), ast_safe_mkdir(), ast_stir_shaken_attest(), ast_stir_shaken_vs_verify(), crypto_get_cert_subject(), crypto_log_openssl(), curl_write_data_free(), module_destroy(), restrictedFile(), safe_mkdir(), split_path(), and stasis_app_stored_recording_find_by_name().
void * ast_std_malloc | ( | size_t | size | ) |