diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk.h | 3 | ||||
-rw-r--r-- | include/asterisk/_private.h | 19 | ||||
-rw-r--r-- | include/asterisk/acl.h | 18 | ||||
-rw-r--r-- | include/asterisk/astmm.h | 202 | ||||
-rw-r--r-- | include/asterisk/autoconfig.h.in | 3 | ||||
-rw-r--r-- | include/asterisk/ccss.h | 11 | ||||
-rw-r--r-- | include/asterisk/cdr.h | 6 | ||||
-rw-r--r-- | include/asterisk/channel.h | 54 | ||||
-rw-r--r-- | include/asterisk/config.h | 10 | ||||
-rw-r--r-- | include/asterisk/devicestate.h | 36 | ||||
-rw-r--r-- | include/asterisk/dsp.h | 12 | ||||
-rw-r--r-- | include/asterisk/enum.h | 3 | ||||
-rw-r--r-- | include/asterisk/features_config.h | 6 | ||||
-rw-r--r-- | include/asterisk/logger.h | 11 | ||||
-rw-r--r-- | include/asterisk/manager.h | 6 | ||||
-rw-r--r-- | include/asterisk/module.h | 15 | ||||
-rw-r--r-- | include/asterisk/options.h | 13 | ||||
-rw-r--r-- | include/asterisk/rtp_engine.h | 2 | ||||
-rw-r--r-- | include/asterisk/sounds_index.h | 8 | ||||
-rw-r--r-- | include/asterisk/stringfields.h | 44 | ||||
-rw-r--r-- | include/asterisk/udptl.h | 7 | ||||
-rw-r--r-- | include/asterisk/utils.h | 358 |
22 files changed, 211 insertions, 636 deletions
diff --git a/include/asterisk.h b/include/asterisk.h index 27d66b776..c1ed6af3f 100644 --- a/include/asterisk.h +++ b/include/asterisk.h @@ -20,10 +20,7 @@ #include "asterisk/autoconfig.h" #include "asterisk/compat.h" - -#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2) #include "asterisk/astmm.h" -#endif /* Default to allowing the umask or filesystem ACLs to determine actual file * creation permissions diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h index b9f552dd1..431f96108 100644 --- a/include/asterisk/_private.h +++ b/include/asterisk/_private.h @@ -33,26 +33,17 @@ int astdb_init(void); /*!< Provided by db.c */ int ast_channels_init(void); /*!< Provided by channel.c */ void ast_builtins_init(void); /*!< Provided by cli.c */ int ast_cli_perms_init(int reload); /*!< Provided by cli.c */ -int dnsmgr_init(void); /*!< Provided by dnsmgr.c */ void dnsmgr_start_refresh(void); /*!< Provided by dnsmgr.c */ -int dnsmgr_reload(void); /*!< Provided by dnsmgr.c */ int ast_dns_system_resolver_init(void); /*!< Provided by dns_system_resolver.c */ void threadstorage_init(void); /*!< Provided by threadstorage.c */ int ast_device_state_engine_init(void); /*!< Provided by devicestate.c */ int astobj2_init(void); /*!< Provided by astobj2.c */ int ast_named_locks_init(void); /*!< Provided by named_locks.c */ int ast_file_init(void); /*!< Provided by file.c */ -int ast_features_init(void); /*!< Provided by features.c */ void ast_autoservice_init(void); /*!< Provided by autoservice.c */ -int ast_http_init(void); /*!< Provided by http.c */ -int ast_http_reload(void); /*!< Provided by http.c */ int ast_tps_init(void); /*!< Provided by taskprocessor.c */ int ast_timing_init(void); /*!< Provided by timing.c */ -int ast_indications_init(void); /*!< Provided by indications.c */ -int ast_indications_reload(void);/*!< Provided by indications.c */ void ast_stun_init(void); /*!< Provided by stun.c */ -int ast_cel_engine_init(void); /*!< Provided by cel.c */ -int ast_cel_engine_reload(void); /*!< Provided by cel.c */ int ast_ssl_init(void); /*!< Provided by ssl.c */ int ast_pj_init(void); /*!< Provided by libasteriskpj.c */ int ast_test_init(void); /*!< Provided by test.c */ @@ -97,13 +88,6 @@ void ast_process_pending_reloads(void); */ int ast_xmldoc_load_documentation(void); -/*! - * \brief Reload genericplc configuration value from codecs.conf - * - * Implementation is in main/channel.c - */ -int ast_plc_reload(void); - /*! \brief initializes the rtp engine arrays */ int ast_rtp_engine_init(void); @@ -113,9 +97,6 @@ int ast_rtp_engine_init(void); */ int ast_parking_stasis_init(void); -/*! \brief initialize the sounds index */ -int ast_sounds_index_init(void); - /*! * \brief Endpoint support initialization. * \return 0 on success. diff --git a/include/asterisk/acl.h b/include/asterisk/acl.h index bda1c7606..09adc527d 100644 --- a/include/asterisk/acl.h +++ b/include/asterisk/acl.h @@ -382,24 +382,6 @@ const char *ast_tos2str(unsigned int tos); struct ast_ha *ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined); /*! - * \brief Initialize and configure the named ACL system. - * - * \details - * This function will prepare the named ACL system for use. - * For this reason, it needs to be called before other things that use ACLs are initialized. - */ -int ast_named_acl_init(void); - -/*! - * \brief reload/reconfigure the named ACL system. - * - * \details - * This function is designed to trigger an event upon a successful reload that may update - * ACL consumers. - */ -int ast_named_acl_reload(void); - -/*! * \brief a \ref stasis_message_type for changes against a named ACL or the set of all named ACLs * \since 12 * diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h index 4e4a65b31..13ebe030c 100644 --- a/include/asterisk/astmm.h +++ b/include/asterisk/astmm.h @@ -17,13 +17,12 @@ */ /*! \file - * \brief Asterisk memory usage debugging - * This file provides headers for MALLOC_DEBUG, a define used for tracking down - * memory leaks. It should never be \#included directly; always use the - * MALLOC_DEBUG definition in menuselect to activate those functions. + * \brief Asterisk memory management routines + * + * This file should never be \#included directly, it is included + * by asterisk.h. */ - #ifdef __cplusplus extern "C" { #endif @@ -32,26 +31,45 @@ extern "C" { #define _ASTERISK_ASTMM_H /* IWYU pragma: private, include "asterisk.h" */ -#if defined(MALLOC_DEBUG) +#if defined(MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2) #define __AST_DEBUG_MALLOC void __ast_mm_init_phase_1(void); void __ast_mm_init_phase_2(void); #endif -void *ast_std_malloc(size_t size); -void *ast_std_calloc(size_t nmemb, size_t size); +void *ast_std_malloc(size_t size) attribute_malloc; +void *ast_std_calloc(size_t nmemb, size_t size) attribute_malloc; void *ast_std_realloc(void *ptr, size_t size); void ast_std_free(void *ptr); + +/*! + * \brief 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. + */ void ast_free_ptr(void *ptr); -void *__ast_repl_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func); -void *__ast_repl_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func); -void *__ast_repl_malloc(size_t size, const char *file, int lineno, const char *func); +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_malloc(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_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) attribute_malloc; +char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func) attribute_malloc; +int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) + __attribute__((format(printf, 5, 6))); +int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) + __attribute__((format(printf, 2, 0))); + +/* The __ast_repl functions should not used from Asterisk sources, they are exposed + * for use by ASTMM_REDIRECT and bundled pjproject. */ +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); -char *__ast_repl_strndup(const char *s, size_t n, 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_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...) __attribute__((format(printf, 5, 6))); int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func) @@ -123,22 +141,22 @@ int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char #if ASTMM_LIBC == ASTMM_REDIRECT /* Redefine libc functions to our own versions */ -#define calloc(a, b) \ - __ast_repl_calloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) -#define malloc(a) \ - __ast_repl_malloc(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) -#define free(a) \ - __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) -#define realloc(a, b) \ - __ast_repl_realloc(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) -#define strdup(a) \ - __ast_repl_strdup(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) -#define strndup(a, b) \ - __ast_repl_strndup(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) -#define asprintf(a, b, c...) \ - __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c) -#define vasprintf(a, b, c) \ - __ast_repl_vasprintf(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define calloc(nmemb, size) \ + __ast_repl_calloc(nmemb, size, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define malloc(size) \ + __ast_repl_malloc(size, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define free(ptr) \ + __ast_free(ptr, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define realloc(ptr, size) \ + __ast_repl_realloc(ptr, size, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define strdup(s) \ + __ast_repl_strdup(s, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define strndup(s, n) \ + __ast_repl_strndup(s, n, __FILE__, __LINE__, __PRETTY_FUNCTION__) +#define asprintf(strp, format, args...) \ + __ast_repl_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, strp, format, args) +#define vasprintf(strp, format, ap) \ + __ast_repl_vasprintf(strp, format, ap, __FILE__, __LINE__, __PRETTY_FUNCTION__) #elif ASTMM_LIBC == ASTMM_BLOCK @@ -171,6 +189,132 @@ int __ast_repl_vasprintf(char **strp, const char *format, va_list ap, const char #define ast_free(a) \ __ast_free(a, __FILE__, __LINE__, __PRETTY_FUNCTION__) +/*! + * \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_cache((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 + \param size The size of the buffer we want allocated + + This macro will attempt to allocate memory from the stack. If it fails + you won't get a NULL returned, but a SEGFAULT if you're lucky. +*/ +#define ast_alloca(size) __builtin_alloca(size) + +#if !defined(ast_strdupa) && defined(__GNUC__) +/*! + * \brief duplicate a string in memory from the stack + * \param s The string to duplicate + * + * This macro will duplicate the given string. It returns a pointer to the stack + * allocatted memory for the new string. + */ +#define ast_strdupa(s) \ + (__extension__ \ + ({ \ + const char *__old = (s); \ + size_t __len = strlen(__old) + 1; \ + char *__new = __builtin_alloca(__len); \ + memcpy (__new, __old, __len); \ + __new; \ + })) +#endif + #else #error "NEVER INCLUDE astmm.h DIRECTLY!!" #endif /* _ASTERISK_ASTMM_H */ diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in index 6d747ae5a..5e9ba6011 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -483,9 +483,6 @@ than `double'. */ #undef HAVE_LONG_DOUBLE_WIDER -/* Define to 1 if you have the libtool library. */ -#undef HAVE_LTDL - /* Define to 1 if you have the Lua library. */ #undef HAVE_LUA diff --git a/include/asterisk/ccss.h b/include/asterisk/ccss.h index fb17500b6..c006c7639 100644 --- a/include/asterisk/ccss.h +++ b/include/asterisk/ccss.h @@ -1618,15 +1618,4 @@ typedef void (*ast_cc_callback_fn)(struct ast_channel *chan, struct ast_cc_confi */ int ast_cc_callback(struct ast_channel *inbound, const char * const tech, const char * const dest, ast_cc_callback_fn callback); -/*! - * \since 1.8 - * \brief Initialize CCSS - * - * Performs startup routines necessary for CC operation. - * - * \retval 0 Success - * \retval nonzero Failure - */ -int ast_cc_init(void); - #endif /* _ASTERISK_CCSS_H */ diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h index e10da8223..c6b241315 100644 --- a/include/asterisk/cdr.h +++ b/include/asterisk/cdr.h @@ -581,12 +581,6 @@ const char *ast_cdr_disp2str(int disposition); */ void ast_cdr_setuserfield(const char *channel_name, const char *userfield); -/*! \brief Reload the configuration file cdr.conf and start/stop CDR scheduling thread */ -int ast_cdr_engine_reload(void); - -/*! \brief Load the configuration file cdr.conf and possibly start the CDR scheduling thread */ -int ast_cdr_engine_init(void); - /*! Submit any remaining CDRs and prepare for shutdown */ void ast_cdr_engine_term(void); diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 8cb03800e..16f9aa8ae 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -1144,22 +1144,6 @@ enum ama_flags { * take a channel argument. */ -/*! - * \brief Create a channel data store object - * \deprecated You should use the ast_datastore_alloc() generic function instead. - * \version 1.6.1 deprecated - */ -struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid) - __attribute__((deprecated)); - -/*! - * \brief Free a channel data store object - * \deprecated You should use the ast_datastore_free() generic function instead. - * \version 1.6.1 deprecated - */ -int ast_channel_datastore_free(struct ast_datastore *datastore) - __attribute__((deprecated)); - /*! \brief Inherit datastores from a parent to a child. */ int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to); @@ -1710,21 +1694,6 @@ void ast_channel_softhangup_withcause_locked(struct ast_channel *chan, int cause /*! * \brief Compare a offset with the settings of when to hang a channel up - * \param chan channel on which to check for hang up - * \param offset offset in seconds from current time - * \return 1, 0, or -1 - * \details - * This function compares a offset from current time with the absolute time - * out on a channel (when to hang up). If the absolute time out on a channel - * is earlier than current time plus the offset, it returns 1, if the two - * time values are equal, it return 0, otherwise, it return -1. - * \sa ast_channel_cmpwhentohangup_tv() - * \version 1.6.1 deprecated function (only had seconds precision) - */ -int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated)); - -/*! - * \brief Compare a offset with the settings of when to hang a channel up * \param chan channel on which to check for hangup * \param offset offset in seconds and microseconds from current time * \return 1, 0, or -1 @@ -1740,23 +1709,6 @@ int ast_channel_cmpwhentohangup_tv(struct ast_channel *chan, struct timeval offs * \brief Set when to hang a channel up * * \param chan channel on which to check for hang up - * \param offset offset in seconds relative to the current time of when to hang up - * - * \details - * This function sets the absolute time out on a channel (when to hang up). - * - * \pre chan is locked - * - * \return Nothing - * \sa ast_channel_setwhentohangup_tv() - * \version 1.6.1 deprecated function (only had seconds precision) - */ -void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset) __attribute__((deprecated)); - -/*! - * \brief Set when to hang a channel up - * - * \param chan channel on which to check for hang up * \param offset offset in seconds and useconds relative to the current time of when to hang up * * This function sets the absolute time out on a channel (when to hang up). @@ -2736,12 +2688,6 @@ int ast_namedgroups_intersect(struct ast_namedgroups *a, struct ast_namedgroups /*! \brief Print named call groups and named pickup groups */ char *ast_print_namedgroups(struct ast_str **buf, struct ast_namedgroups *groups); -/*! - * \brief Convert enum channelreloadreason to text string for manager event - * \param reason The reason for reload (manager, cli, start etc) - */ -const char *channelreloadreason2txt(enum channelreloadreason reason); - /*! \brief return an ast_variable list of channeltypes */ struct ast_variable *ast_channeltype_list(void); diff --git a/include/asterisk/config.h b/include/asterisk/config.h index 891284039..9908b905b 100644 --- a/include/asterisk/config.h +++ b/include/asterisk/config.h @@ -784,15 +784,6 @@ int ast_realtime_append_mapping(const char *name, const char *driver, const char */ int register_config_cli(void); -/*! - * \brief Exposed re-initialization method for core process - * - * \details - * This method is intended for use only with the core re-initialization and is - * not designed to be called from any user applications. - */ -int read_config_maps(void); - /*! \brief Create a new base configuration structure */ struct ast_config *ast_config_new(void); @@ -994,7 +985,6 @@ int ast_config_text_file_save2(const char *filename, const struct ast_config *cf * \return 0 on success or -1 on failure. */ int ast_config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator); -int config_text_file_save(const char *filename, const struct ast_config *cfg, const char *generator) __attribute__((deprecated)); struct ast_config *ast_config_internal_load(const char *configfile, struct ast_config *cfg, struct ast_flags flags, const char *suggested_incl_file, const char *who_asked); /*! diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h index 4f9aa739b..5b2f04de4 100644 --- a/include/asterisk/devicestate.h +++ b/include/asterisk/devicestate.h @@ -86,7 +86,6 @@ enum ast_device_state ast_state_chan2dev(enum ast_channel_state chanstate); * * \param devstate Current device state */ -const char *devstate2str(enum ast_device_state devstate) attribute_pure __attribute__((deprecated)); const char *ast_devstate2str(enum ast_device_state devstate) attribute_pure; /*! @@ -167,41 +166,6 @@ int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache ca int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device); /*! - * \brief Tells Asterisk the State for Device is changed. - * (Accept change notification, add it to change queue.) - * - * \param fmt device name like a dial string with format parameters - * - * Asterisk polls the new extension states and calls the registered - * callbacks for the changed extensions - * - * \retval 0 on success - * \retval -1 on failure - * - * \note This is deprecated in favor of ast_devstate_changed() - * \version 1.6.1 deprecated - */ -int ast_device_state_changed(const char *fmt, ...) - __attribute__((deprecated,format(printf, 1, 2))); - -/*! - * \brief Tells Asterisk the State for Device is changed - * - * \param device device name like a dial string - * - * Asterisk polls the new extension states and calls the registered - * callbacks for the changed extensions - * - * \retval 0 on success - * \retval -1 on failure - * - * \note This is deprecated in favor of ast_devstate_changed_literal() - * \version 1.6.1 deprecated - */ -int ast_device_state_changed_literal(const char *device) - __attribute__((deprecated)); - -/*! * \brief Add device state provider * * \param label to use in hint, like label:object diff --git a/include/asterisk/dsp.h b/include/asterisk/dsp.h index d092e6b4c..769d3b981 100644 --- a/include/asterisk/dsp.h +++ b/include/asterisk/dsp.h @@ -193,16 +193,4 @@ int ast_dsp_get_tcount(struct ast_dsp *dsp); */ int ast_dsp_get_threshold_from_settings(enum threshold which); -/*! - * \brief Reloads dsp settings from dsp.conf - * \since 1.6.1 - */ -int ast_dsp_reload(void); - -/*! - * \brief Load dsp settings from dsp.conf - * \since 1.6.1 - */ -int ast_dsp_init(void); - #endif /* _ASTERISK_DSP_H */ diff --git a/include/asterisk/enum.h b/include/asterisk/enum.h index 877c0c3cf..2ce85ccb3 100644 --- a/include/asterisk/enum.h +++ b/include/asterisk/enum.h @@ -97,7 +97,4 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *location, i */ int ast_get_txt(struct ast_channel *chan, const char *number, char *txt, int maxtxt, char *suffix); -int ast_enum_init(void); -int ast_enum_reload(void); - #endif /* _ASTERISK_ENUM_H */ diff --git a/include/asterisk/features_config.h b/include/asterisk/features_config.h index 1bce50bba..cd1bbbcea 100644 --- a/include/asterisk/features_config.h +++ b/include/asterisk/features_config.h @@ -265,10 +265,4 @@ struct ast_applicationmap_item { */ struct ao2_container *ast_get_chan_applicationmap(struct ast_channel *chan); -void ast_features_config_shutdown(void); - -int ast_features_config_reload(void); - -int ast_features_config_init(void); - #endif /* _FEATURES_CONFIG_H */ diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h index 8b1e5fe01..56dd85985 100644 --- a/include/asterisk/logger.h +++ b/include/asterisk/logger.h @@ -133,9 +133,6 @@ int ast_logger_remove_channel(const char *log_channel); */ void ast_log_backtrace(void); -/*! \brief Reload logger without rotating log files */ -int logger_reload(void); - /*! \brief Reload logger while rotating log files */ int ast_logger_rotate(void); @@ -310,14 +307,6 @@ void ast_console_toggle_loglevel(int fd, int level, int state); unsigned int ast_debug_get_by_module(const char *module); /*! - * \brief Get the verbose level for a module - * \param module the name of module - * \return the verbose level - * \version 11.0.0 deprecated - */ -unsigned int ast_verbose_get_by_module(const char *module) __attribute__((deprecated)); - -/*! * \brief Register a new logger level * \param name The name of the level to be registered * \retval -1 if an error occurs diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h index 35dc22763..97d4b9c29 100644 --- a/include/asterisk/manager.h +++ b/include/asterisk/manager.h @@ -356,12 +356,6 @@ void __attribute__((format(printf, 2, 3))) astman_append(struct mansession *s, c /*! \brief Determinie if a manager session ident is authenticated */ int astman_is_authed(uint32_t ident); -/*! \brief Called by Asterisk initialization */ -int init_manager(void); - -/*! \brief Called by Asterisk module functions and the CLI command */ -int reload_manager(void); - /*! * \brief Add a datastore to a session * diff --git a/include/asterisk/module.h b/include/asterisk/module.h index ebd41c06d..faa4f7f67 100644 --- a/include/asterisk/module.h +++ b/include/asterisk/module.h @@ -292,13 +292,14 @@ enum ast_module_load_priority { AST_MODPRI_REALTIME_DEPEND = 10, /*!< Dependency for a realtime driver */ AST_MODPRI_REALTIME_DEPEND2 = 20, /*!< Second level dependency for a realtime driver (func_curl needs res_curl, but is needed by res_config_curl) */ AST_MODPRI_REALTIME_DRIVER = 30, /*!< A realtime driver, which provides configuration services for other modules */ - AST_MODPRI_TIMING = 40, /*!< Dependency for a channel (MOH needs timing interfaces to be fully loaded) */ - AST_MODPRI_CHANNEL_DEPEND = 50, /*!< Channel driver dependency (may depend upon realtime, e.g. MOH) */ - AST_MODPRI_CHANNEL_DRIVER = 60, /*!< Channel drivers (provide devicestate) */ - AST_MODPRI_APP_DEPEND = 70, /*!< Dependency for an application */ - AST_MODPRI_DEVSTATE_PROVIDER = 80, /*!< Applications and other modules that _provide_ devicestate (e.g. meetme) */ - AST_MODPRI_DEVSTATE_PLUGIN = 90, /*!< Plugin for a module that provides devstate (e.g. res_calendar_*) */ - AST_MODPRI_CDR_DRIVER = 100, /*!< CDR or CEL backend */ + AST_MODPRI_CORE = 40, /*!< A core module originally meant to start between preload and load. */ + AST_MODPRI_TIMING = 50, /*!< Dependency for a channel (MOH needs timing interfaces to be fully loaded) */ + AST_MODPRI_CHANNEL_DEPEND = 60, /*!< Channel driver dependency (may depend upon realtime, e.g. MOH) */ + AST_MODPRI_CHANNEL_DRIVER = 70, /*!< Channel drivers (provide devicestate) */ + AST_MODPRI_APP_DEPEND = 80, /*!< Dependency for an application */ + AST_MODPRI_DEVSTATE_PROVIDER = 90, /*!< Applications and other modules that _provide_ devicestate (e.g. meetme) */ + AST_MODPRI_DEVSTATE_PLUGIN = 100, /*!< Plugin for a module that provides devstate (e.g. res_calendar_*) */ + AST_MODPRI_CDR_DRIVER = 110, /*!< CDR or CEL backend */ AST_MODPRI_DEFAULT = 128, /*!< Modules not otherwise defined (such as most apps) will load here */ AST_MODPRI_DEVSTATE_CONSUMER = 150, /*!< Certain modules, which consume devstate, need to load after all others (e.g. app_queue) */ }; diff --git a/include/asterisk/options.h b/include/asterisk/options.h index 78f596a88..6c4e55295 100644 --- a/include/asterisk/options.h +++ b/include/asterisk/options.h @@ -74,8 +74,6 @@ enum ast_option_flags { AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17), /*! Suppress some warnings */ AST_OPT_FLAG_DONT_WARN = (1 << 18), - /*! End CDRs before the 'h' extension */ - AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19), /*! Reference Debugging */ AST_OPT_FLAG_REF_DEBUG = (1 << 20), /*! Always fork, even if verbose or debug settings are non-zero */ @@ -84,12 +82,8 @@ enum ast_option_flags { AST_OPT_FLAG_MUTE = (1 << 22), /*! There is a per-module debug setting */ AST_OPT_FLAG_DEBUG_MODULE = (1 << 23), - /*! There is a per-module verbose setting */ - AST_OPT_FLAG_VERBOSE_MODULE = (1 << 24), /*! Terminal colors should be adjusted for a light-colored background */ AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25), - /*! Count Initiated seconds in CDR's */ - AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26), /*! Force black background */ AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27), /*! Hide remote console connect messages on console */ @@ -98,6 +92,8 @@ enum ast_option_flags { AST_OPT_FLAG_LOCK_CONFIG_DIR = (1 << 29), /*! Generic PLC */ AST_OPT_FLAG_GENERIC_PLC = (1 << 30), + /*! Generic PLC onm equal codecs */ + AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS = (1 << 31), }; /*! These are the options that set by default when Asterisk starts */ @@ -123,17 +119,16 @@ enum ast_option_flags { #define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT) #define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE) #define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN) -#define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN) #define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK) #define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE) #define ast_opt_dbg_module ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_MODULE) -#define ast_opt_verb_module ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_MODULE) #define ast_opt_light_background ast_test_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND) #define ast_opt_force_black_background ast_test_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND) #define ast_opt_hide_connect ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT) #define ast_opt_lock_confdir ast_test_flag(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR) #define ast_opt_generic_plc ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC) #define ast_opt_ref_debug ast_test_flag(&ast_options, AST_OPT_FLAG_REF_DEBUG) +#define ast_opt_generic_plc_on_equal_codecs ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS) /*! Maximum log level defined by PJPROJECT. */ #define MAX_PJ_LOG_MAX_LEVEL 6 @@ -199,8 +194,6 @@ extern struct timeval ast_lastreloadtime; extern pid_t ast_mainpid; extern char record_cache_dir[AST_CACHE_DIR_LEN]; -extern char dahdi_chan_name[AST_CHANNEL_NAME]; -extern int dahdi_chan_name_len; extern int ast_language_is_prefix; diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h index 3812cb159..4e32d6b32 100644 --- a/include/asterisk/rtp_engine.h +++ b/include/asterisk/rtp_engine.h @@ -126,6 +126,8 @@ enum ast_rtp_property { AST_RTP_PROPERTY_RETRANS_RECV, /*! Enable packet retransmission for sent packets */ AST_RTP_PROPERTY_RETRANS_SEND, + /*! Enable REMB sending and receiving passthrough support */ + AST_RTP_PROPERTY_REMB, /*! * \brief Maximum number of RTP properties supported diff --git a/include/asterisk/sounds_index.h b/include/asterisk/sounds_index.h index d7eb05332..bbd3965f4 100644 --- a/include/asterisk/sounds_index.h +++ b/include/asterisk/sounds_index.h @@ -33,14 +33,6 @@ extern "C" { struct ast_media_index; /*! - * \brief Reload the sounds index - * - * \retval zero on success - * \retval non-zero on failure - */ -int ast_sounds_reindex(void); - -/*! * \brief Get the sounds index * * \retval sounds index (must be ao2_cleanup()'ed) diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h index e1ff2fc1d..ce978901b 100644 --- a/include/asterisk/stringfields.h +++ b/include/asterisk/stringfields.h @@ -228,11 +228,6 @@ struct ast_string_field_mgr { ast_string_field last_alloc; /*!< the last field allocated */ struct ast_string_field_pool *embedded_pool; /*!< pointer to the embedded pool, if any */ struct ast_string_field_vector string_fields; /*!< field vector for compare and copy */ - /* v-- MALLOC_DEBUG information */ - const char *owner_file; /*!< filename of owner */ - const char *owner_func; /*!< function name of owner */ - int owner_line; /*!< line number of owner */ - /* ^-- MALLOC_DEBUG information */ }; /*! @@ -266,7 +261,8 @@ int __ast_string_field_ptr_grow(struct ast_string_field_mgr *mgr, an additional pool will be allocated. */ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr, - struct ast_string_field_pool **pool_head, size_t needed); + struct ast_string_field_pool **pool_head, size_t needed, + const char *file, int lineno, const char *func); /*! \internal @@ -277,9 +273,9 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr \param format printf-style format string \return nothing */ -void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, - struct ast_string_field_pool **pool_head, - ast_string_field *ptr, const char *format, ...) __attribute__((format(printf, 4, 5))); +void __ast_string_field_ptr_build(const char *file, int lineno, const char *func, + struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, + ast_string_field *ptr, const char *format, ...) __attribute__((format(printf, 7, 8))); /*! \internal @@ -292,8 +288,9 @@ void __ast_string_field_ptr_build(struct ast_string_field_mgr *mgr, \return nothing */ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr, - struct ast_string_field_pool **pool_head, - ast_string_field *ptr, const char *format, va_list ap) __attribute__((format(printf, 4, 0))); + struct ast_string_field_pool **pool_head, + ast_string_field *ptr, const char *format, va_list ap, + const char *file, int lineno, const char *func) __attribute__((format(printf, 4, 0))); /*! \brief Declare a string field @@ -479,7 +476,7 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, __res__; \ }) -#define ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data) \ +#define __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, file, lineno, func) \ ({ \ int __res__ = 0; \ const char *__d__ = (data); \ @@ -491,7 +488,7 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, *__p__ = __ast_string_field_empty; \ } else if ((__dlen__ <= AST_STRING_FIELD_ALLOCATION(*__p__)) || \ (!__ast_string_field_ptr_grow(&field_mgr, &field_mgr_pool, __dlen__, __p__)) || \ - (target = __ast_string_field_alloc_space(&field_mgr, &field_mgr_pool, __dlen__))) { \ + (target = __ast_string_field_alloc_space(&field_mgr, &field_mgr_pool, __dlen__, file, lineno, func))) { \ if (target != *__p__) { \ __ast_string_field_release_active(field_mgr_pool, *__p__); \ *__p__ = target; \ @@ -503,6 +500,9 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, __res__; \ }) +#define ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data) \ + __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) + /*! \brief Set a field to a simple string value \param x Pointer to a structure containing fields @@ -532,7 +532,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, ({ \ int __res__ = -1; \ if (((void *)(x)) != NULL) { \ - __ast_string_field_ptr_build(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args); \ + __ast_string_field_ptr_build(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ + &(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args); \ __res__ = 0; \ } \ __res__; \ @@ -550,7 +551,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, ({ \ int __res__ = -1; \ if (((void *)(x)) != NULL) { \ - __ast_string_field_ptr_build(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args); \ + __ast_string_field_ptr_build(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ + &(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args); \ __res__ = 0; \ } \ __res__; \ @@ -568,7 +570,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, ({ \ int __res__ = -1; \ if (((void *)(x)) != NULL) { \ - __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args); \ + __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args, \ + __FILE__, __LINE__, __PRETTY_FUNCTION__); \ __res__ = 0; \ } \ __res__; \ @@ -586,7 +589,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, ({ \ int __res__ = -1; \ if (((void *)(x)) != NULL) { \ - __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args); \ + __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args, \ + __FILE__, __LINE__, __PRETTY_FUNCTION__); \ __res__ = 0; \ } \ __res__; \ @@ -626,12 +630,14 @@ int __ast_string_fields_cmp(struct ast_string_field_vector *left, struct ast_str if (((void *)(copy)) != NULL && ((void *)(orig)) != NULL) { \ __res__ = __ast_string_fields_copy(((copy)->__field_mgr_pool), \ (struct ast_string_field_mgr *)&((copy)->__field_mgr), \ - (struct ast_string_field_mgr *)&((orig)->__field_mgr)); \ + (struct ast_string_field_mgr *)&((orig)->__field_mgr), \ + __FILE__, __LINE__, __PRETTY_FUNCTION__); \ } \ __res__; \ }) int __ast_string_fields_copy(struct ast_string_field_pool *copy_pool, - struct ast_string_field_mgr *copy_mgr, struct ast_string_field_mgr *orig_mgr); + struct ast_string_field_mgr *copy_mgr, struct ast_string_field_mgr *orig_mgr, + const char *file, int lineno, const char *func); #endif /* _ASTERISK_STRINGFIELDS_H */ diff --git a/include/asterisk/udptl.h b/include/asterisk/udptl.h index 7137ff936..0d79d6f66 100644 --- a/include/asterisk/udptl.h +++ b/include/asterisk/udptl.h @@ -126,13 +126,6 @@ void ast_udptl_setnat(struct ast_udptl *udptl, int nat); void ast_udptl_stop(struct ast_udptl *udptl); -void ast_udptl_init(void); - -/*! - * \version 1.6.1 return changed to int - */ -int ast_udptl_reload(void); - #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index bb9aa2a3c..4da7fa465 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -484,364 +484,6 @@ long int ast_random(void); #define ast_random_double() (((double)ast_random()) / RAND_MAX) /*! - * \brief DEBUG_CHAOS returns failure randomly - * - * DEBUG_CHAOS_RETURN(failure); can be used to fake - * failure of functions such as memory allocation, - * for the purposes of testing failure handling. - */ -#ifdef DEBUG_CHAOS -#ifndef DEBUG_CHAOS_ALLOC_CHANCE -#define DEBUG_CHAOS_ALLOC_CHANCE 100000 -#endif -/* Could #define DEBUG_CHAOS_ENABLE ast_fully_booted */ -#ifndef DEBUG_CHAOS_ENABLE -#define DEBUG_CHAOS_ENABLE 1 -#endif -#define DEBUG_CHAOS_RETURN(CHANCE, FAILURE) \ - do { \ - if ((DEBUG_CHAOS_ENABLE) && (ast_random() % CHANCE == 0)) { \ - return FAILURE; \ - } \ - } while (0) -#else -#define DEBUG_CHAOS_RETURN(c,f) -#endif - - -#if !defined(NO_MALLOC_DEBUG) && !defined(STANDALONE) && !defined(STANDALONE2) -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); - -/*! - * \brief 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. - */ -void ast_free_ptr(void *ptr); -void __ast_free(void *ptr, const char *file, int lineno, const char *func); - -#else - -/* - * Need to defeat the MALLOC_DEBUG API when building the standalone utilities. - */ - -#define ast_std_malloc malloc -#define ast_std_calloc calloc -#define ast_std_realloc realloc -#define ast_std_free free - -#define ast_free_ptr free -#define ast_free free - -#define __ast_repl_calloc(nmemb, size, file, lineno, func) \ - calloc(nmemb, size) - -#define __ast_repl_calloc_cache(nmemb, size, file, lineno, func) \ - calloc(nmemb, size) - -#define __ast_repl_malloc(size, file, lineno, func) \ - malloc(size) - -#define __ast_repl_realloc(ptr, size, file, lineno, func) \ - realloc(ptr, size) - -#define __ast_repl_strdup(s, file, lineno, func) \ - strdup(s) - -#define __ast_repl_strndup(s, n, file, lineno, func) \ - strndup(s, n) - -#define __ast_repl_vasprintf(strp, format, ap, file, lineno, func) \ - vasprintf(strp, format, ap) -#endif - -#if defined(AST_IN_CORE) -#define MALLOC_FAILURE_MSG \ - ast_log_safe(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file) -#else -#define MALLOC_FAILURE_MSG \ - ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file) -#endif - -AST_INLINE_API( -void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, const char *func), -{ - void *p; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - p = __ast_repl_malloc(len, file, lineno, func); - if (!p) { - MALLOC_FAILURE_MSG; - } - - return p; -} -) - -AST_INLINE_API( -void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func), -{ - void *p; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - p = __ast_repl_calloc(num, len, file, lineno, func); - if (!p) { - MALLOC_FAILURE_MSG; - } - - return p; -} -) - -AST_INLINE_API( -void * attribute_malloc __ast_calloc_cache(size_t num, size_t len, const char *file, int lineno, const char *func), -{ - void *p; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - p = __ast_repl_calloc_cache(num, len, file, lineno, func); - if (!p) { - MALLOC_FAILURE_MSG; - } - - return p; -} -) - -AST_INLINE_API( -void *__ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func), -{ - void *newp; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - newp = __ast_repl_realloc(p, len, file, lineno, func); - if (!newp) { - MALLOC_FAILURE_MSG; - } - - return newp; -} -) - -AST_INLINE_API( -char * attribute_malloc __ast_strdup(const char *str, const char *file, int lineno, const char *func), -{ - char *newstr = NULL; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - if (str) { - newstr = __ast_repl_strdup(str, file, lineno, func); - if (!newstr) { - MALLOC_FAILURE_MSG; - } - } - - return newstr; -} -) - -AST_INLINE_API( -char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func), -{ - char *newstr = NULL; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - if (str) { - newstr = __ast_repl_strndup(str, len, file, lineno, func); - if (!newstr) { - MALLOC_FAILURE_MSG; - } - } - - return newstr; -} -) - -AST_INLINE_API( -__attribute__((format(printf, 5, 6))) -int __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...), -{ - int res; - va_list ap; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1); - - va_start(ap, fmt); - res = __ast_repl_vasprintf(ret, fmt, ap, file, lineno, func); - if (res < 0) { - /* - * *ret is undefined so set to NULL to ensure it is - * initialized to something useful. - */ - *ret = NULL; - MALLOC_FAILURE_MSG; - } - va_end(ap); - - return res; -} -) - -AST_INLINE_API( -__attribute__((format(printf, 2, 0))) -int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, int lineno, const char *func), -{ - int res; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1); - - res = __ast_repl_vasprintf(ret, fmt, ap, file, lineno, func); - if (res < 0) { - /* - * *ret is undefined so set to NULL to ensure it is - * initialized to something useful. - */ - *ret = NULL; - MALLOC_FAILURE_MSG; - } - - return res; -} -) - -/*! - * \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_cache((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 - \param size The size of the buffer we want allocated - - This macro will attempt to allocate memory from the stack. If it fails - you won't get a NULL returned, but a SEGFAULT if you're lucky. -*/ -#define ast_alloca(size) __builtin_alloca(size) - -#if !defined(ast_strdupa) && defined(__GNUC__) -/*! - * \brief duplicate a string in memory from the stack - * \param s The string to duplicate - * - * This macro will duplicate the given string. It returns a pointer to the stack - * allocatted memory for the new string. - */ -#define ast_strdupa(s) \ - (__extension__ \ - ({ \ - const char *__old = (s); \ - size_t __len = strlen(__old) + 1; \ - char *__new = __builtin_alloca(__len); \ - memcpy (__new, __old, __len); \ - __new; \ - })) -#endif - -/*! * \brief Disable PMTU discovery on a socket * \param sock The socket to manipulate * \return Nothing |