Asterisk - The Open Source Telephony Project
21.4.1
|
Vector container support. More...
#include "asterisk/lock.h"
Go to the source code of this file.
Data Structures | |
struct | ast_vector_const_string |
struct | ast_vector_int |
Integer vector definition. More... | |
struct | ast_vector_string |
String vector definitions. More... | |
Macros | |
#define | __make_room(idx, vec) |
#define | AST_VECTOR(name, type) |
Define a vector structure. More... | |
#define | AST_VECTOR_ADD_SORTED(vec, elem, cmp) |
Add an element into a sorted vector. More... | |
#define | AST_VECTOR_APPEND(vec, elem) |
Append an element to a vector, growing the vector if needed. More... | |
#define | AST_VECTOR_CALLBACK(vec, callback, default_value, ...) |
Execute a callback on every element in a vector returning the first matched. More... | |
#define | AST_VECTOR_CALLBACK_MULTIPLE(vec, callback, ...) |
Execute a callback on every element in a vector returning the matching elements in a new vector. More... | |
#define | AST_VECTOR_CALLBACK_VOID(vec, callback, ...) |
Execute a callback on every element in a vector disregarding callback return. More... | |
#define | AST_VECTOR_COMPACT(vec) |
Resize a vector so that its capacity is the same as its size. More... | |
#define | AST_VECTOR_DEFAULT(vec, size, value) |
Default a vector up to size with the given value. More... | |
#define | AST_VECTOR_ELEM_CLEANUP_NOOP(elem) |
Vector element cleanup that does nothing. More... | |
#define | AST_VECTOR_ELEM_DEFAULT_CMP(elem, value) ((elem) == (value)) |
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED() More... | |
#define | AST_VECTOR_FREE(vec) |
Deallocates this vector. More... | |
#define | AST_VECTOR_GET(vec, idx) |
Get an element from a vector. More... | |
#define | AST_VECTOR_GET_ADDR(vec, idx) |
Get an address of element in a vector. More... | |
#define | AST_VECTOR_GET_CMP(vec, value, cmp) |
Get an element from a vector that matches the given comparison. More... | |
#define | AST_VECTOR_GET_INDEX(vec, value, cmp) AST_VECTOR_GET_INDEX_NTH(vec, 1, value, cmp) |
Get the 1st index from a vector that matches the given comparison. More... | |
#define | AST_VECTOR_GET_INDEX_NTH(vec, nth, value, cmp) |
Get the nth index from a vector that matches the given comparison. More... | |
#define | AST_VECTOR_INIT(vec, size) |
Initialize a vector. More... | |
#define | AST_VECTOR_INSERT_AT(vec, idx, elem) |
Insert an element at a specific position in a vector, growing the vector if needed. More... | |
#define | AST_VECTOR_MATCH_ALL(element) (CMP_MATCH) |
Default callback for AST_VECTOR_CALLBACK() More... | |
#define | AST_VECTOR_MAX_SIZE(vec) (vec)->max |
Get the maximum number of elements the vector can currently hold. More... | |
#define | AST_VECTOR_PTR_FREE(vec) |
Deallocates this vector pointer. More... | |
#define | AST_VECTOR_REMOVE(vec, idx, preserve_ordered) |
Remove an element from a vector by index. More... | |
#define | AST_VECTOR_REMOVE_ALL_CMP_ORDERED(vec, value, cmp, cleanup) |
Remove all elements from a vector that matches the given comparison while maintaining order. More... | |
#define | AST_VECTOR_REMOVE_ALL_CMP_UNORDERED(vec, value, cmp, cleanup) |
Remove all elements from a vector that matches the given comparison. More... | |
#define | AST_VECTOR_REMOVE_CMP_ORDERED(vec, value, cmp, cleanup) |
Remove an element from a vector that matches the given comparison while maintaining order. More... | |
#define | AST_VECTOR_REMOVE_CMP_UNORDERED(vec, value, cmp, cleanup) |
Remove an element from a vector that matches the given comparison. More... | |
#define | AST_VECTOR_REMOVE_ELEM_ORDERED(vec, elem, cleanup) |
Remove an element from a vector while maintaining order. More... | |
#define | AST_VECTOR_REMOVE_ELEM_UNORDERED(vec, elem, cleanup) |
Remove an element from a vector. More... | |
#define | AST_VECTOR_REMOVE_ORDERED(vec, idx) AST_VECTOR_REMOVE(vec, idx, 1) |
Remove an element from a vector by index while maintaining order. More... | |
#define | AST_VECTOR_REMOVE_UNORDERED(vec, idx) AST_VECTOR_REMOVE(vec, idx, 0) |
Remove an element from an unordered vector by index. More... | |
#define | AST_VECTOR_REPLACE(vec, idx, elem) |
Replace an element at a specific position in a vector, growing the vector if needed. More... | |
#define | AST_VECTOR_RESET(vec, cleanup) |
Reset vector. More... | |
#define | AST_VECTOR_RW(name, type) |
Define a vector structure with a read/write lock. More... | |
#define | AST_VECTOR_RW_FREE(vec) |
Deallocates this locked vector. More... | |
#define | AST_VECTOR_RW_INIT(vec, size) |
Initialize a vector with a read/write lock. More... | |
#define | AST_VECTOR_RW_PTR_FREE(vec) |
Deallocates this locked vector pointer. More... | |
#define | AST_VECTOR_RW_RDLOCK(vec) ast_rwlock_rdlock(&(vec)->lock) |
Obtain read lock on vector. More... | |
#define | AST_VECTOR_RW_RDLOCK_TIMED(vec, timespec) ast_rwlock_timedrdlock(&(vec)->lock, timespec) |
Try to obtain read lock on vector failing after timeout if unable. More... | |
#define | AST_VECTOR_RW_RDLOCK_TRY(vec) ast_rwlock_tryrdlock(&(vec)->lock) |
Try to obtain read lock on vector failing immediately if unable. More... | |
#define | AST_VECTOR_RW_UNLOCK(vec) ast_rwlock_unlock(&(vec)->lock) |
Unlock vector. More... | |
#define | AST_VECTOR_RW_WRLOCK(vec) ast_rwlock_wrlock(&(vec)->lock) |
Obtain write lock on vector. More... | |
#define | AST_VECTOR_RW_WRLOCK_TIMED(vec, timespec) ast_rwlock_timedwrlock(&(vec)->lock, timespec) |
Try to obtain write lock on vector failing after timeout if unable. More... | |
#define | AST_VECTOR_RW_WRLOCK_TRY(vec) ast_rwlock_trywrlock(&(vec)->lock) |
Try to obtain write lock on vector failing immediately if unable. More... | |
#define | AST_VECTOR_SIZE(vec) (vec)->current |
Get the number of elements in a vector. More... | |
#define | AST_VECTOR_SORT(vec, cmp) |
Sort a vector in-place. More... | |
#define | AST_VECTOR_STEAL_ELEMENTS(vec) |
Steal the elements from a vector and reinitialize. More... | |
Enumerations | |
enum | ast_vector_string_split_flags { AST_VECTOR_STRING_SPLIT_NO_TRIM = 0x01, AST_VECTOR_STRING_SPLIT_ALLOW_EMPTY = 0x02 } |
Functions | |
int | ast_vector_string_split (struct ast_vector_string *dest, const char *input, const char *delim, int flags, int(*excludes_cmp)(const char *s1, const char *s2)) |
Append a string vector by splitting a string. More... | |
Vector container support.
A vector is a variable length array, with properties that can be useful when order doesn't matter.
Definition in file vector.h.
#define AST_VECTOR | ( | name, | |
type | |||
) |
Define a vector structure.
name | Optional vector struct name. |
type | Vector element type. |
Definition at line 44 of file vector.h.
Referenced by build_expression_queue(), create_outgoing_sdp_stream(), and evaluate_history_entry().
#define AST_VECTOR_ADD_SORTED | ( | vec, | |
elem, | |||
cmp | |||
) |
Add an element into a sorted vector.
vec | Sorted vector to add to. |
elem | Element to insert. Must not be an array type. |
cmp | A strcmp compatible compare function. |
0 | on success. |
Non-zero | on failure. |
Definition at line 371 of file vector.h.
Referenced by ast_rtp_read(), load_resource(), and module_deps_missing_recursive().
#define AST_VECTOR_APPEND | ( | vec, | |
elem | |||
) |
Append an element to a vector, growing the vector if needed.
vec | Vector to append to. |
elem | Element to append. |
0 | on success. |
Non-zero | on failure. |
Definition at line 256 of file vector.h.
Referenced by __ast_string_field_init(), add_hintdevice(), ast_cli_allow_at_shutdown(), ast_cli_completion_matches(), ast_context_add_include2(), ast_context_add_switch2(), ast_dns_query_set_add(), ast_dns_txt_get_strings(), ast_msg_handler_register(), ast_msg_tech_register(), ast_multi_object_blob_add(), ast_refer_tech_register(), ast_rtp_bundle(), ast_rtp_instance_extmap_enable(), ast_sip_header_to_security_mechanism(), ast_sip_security_mechanism_vector_init(), ast_sip_security_mechanisms_vector_copy(), ast_sip_str_to_security_mechanism(), ast_sip_transport_monitor_register_replace_key(), ast_stream_topology_append_stream(), ast_stream_topology_clone(), ast_stream_topology_map(), ast_stream_topology_set_stream(), ast_vector_string_split(), build_expression_queue(), create_outgoing_sdp_stream(), device_state_cb(), evaluate_history_entry(), filter_history(), history_on_rx_msg(), history_on_tx_msg(), map_source_to_destinations(), messaging_app_subscribe_endpoint(), optional_api_create(), prometheus_callback_register(), prometheus_metric_register(), prometheus_metrics_provider_register(), softmix_bridge_stream_topology_changed(), stasis_app_control_play_uri(), stasis_app_message_handler(), stasis_forward_all(), stasis_state_add_observer(), topic_add_subscription(), and wizard_mapped_observer().
#define AST_VECTOR_CALLBACK | ( | vec, | |
callback, | |||
default_value, | |||
... | |||
) |
Execute a callback on every element in a vector returning the first matched.
vec | Vector to operate on. |
callback | A callback that takes at least 1 argument (the element) plus number of optional arguments |
default_value | A default value to return if no elements matched |
Definition at line 765 of file vector.h.
Referenced by ast_sorcery_retrieve_by_fields(), and ast_sorcery_retrieve_by_id().
#define AST_VECTOR_CALLBACK_MULTIPLE | ( | vec, | |
callback, | |||
... | |||
) |
Execute a callback on every element in a vector returning the matching elements in a new vector.
This macro basically provides a filtered clone.
vec | Vector to operate on. |
callback | A callback that takes at least 1 argument (the element) plus number of optional arguments |
The following will result in "error: assignment from incompatible pointer type" because these declare 2 different structures.
This will work because you're using the type of the first to declare the second:
This will also work because you're declaring both vector_1 and vector_2 from the same definition.
#define AST_VECTOR_CALLBACK_VOID | ( | vec, | |
callback, | |||
... | |||
) |
Execute a callback on every element in a vector disregarding callback return.
vec | Vector to operate on. |
callback | A callback that takes at least 1 argument (the element) plus number of optional arguments |
Definition at line 862 of file vector.h.
Referenced by __ast_string_field_free_memory(), ast_cli_completion_matches(), ast_cli_completion_vector(), ast_dns_txt_free_strings(), optional_api_destroy(), optional_api_set_impl(), and sorcery_object_type_destructor().
#define AST_VECTOR_COMPACT | ( | vec | ) |
#define AST_VECTOR_DEFAULT | ( | vec, | |
size, | |||
value | |||
) |
Default a vector up to size with the given value.
vec | Vector to default. |
size | The number of elements to default |
value | The default value to set each element to |
#define AST_VECTOR_ELEM_CLEANUP_NOOP | ( | elem | ) |
Vector element cleanup that does nothing.
elem | Element to cleanup |
Definition at line 571 of file vector.h.
Referenced by ast_msg_handler_unregister(), ast_msg_tech_unregister(), ast_refer_tech_unregister(), ast_rtp_bundle(), ast_rtp_destroy(), ast_rtp_read(), event_session_update_websocket(), messaging_app_unsubscribe_endpoint(), optional_api_destroy(), softmix_bridge_stream_topology_changed(), and stasis_state_remove_observer().
#define AST_VECTOR_ELEM_DEFAULT_CMP | ( | elem, | |
value | |||
) | ((elem) == (value)) |
Default comparator for AST_VECTOR_REMOVE_ELEM_UNORDERED()
elem | Element to compare against |
value | Value to compare with the vector element. |
0 | if element does not match. |
Non-zero | if element matches. |
Definition at line 564 of file vector.h.
Referenced by ast_stream_topology_map(), graceful_unload_possible(), module_deps_missing_recursive(), optional_api_destroy(), and softmix_bridge_stream_topology_changed().
#define AST_VECTOR_FREE | ( | vec | ) |
Deallocates this vector.
If any code to free the elements of this vector needs to be run, that should be done prior to this call.
vec | Vector to deallocate. |
Definition at line 174 of file vector.h.
Referenced by __ast_string_field_free_memory(), __ast_string_field_init(), ast_refresh_resource(), ast_rtp_codecs_payloads_destroy(), ast_rtp_codecs_payloads_initialize(), ast_rtp_destroy(), ast_rtp_prop_set(), ast_sip_security_mechanisms_vector_destroy(), ast_stream_topology_map(), ast_update_module_list_data(), build_expression_queue(), create_outgoing_sdp_stream(), dns_query_set_destroy(), evaluate_history_entry(), event_session_shutdown(), filter_history(), format_cap_destroy(), load_modules(), load_resource_list(), messaging_cleanup(), messaging_init(), module_deps_missing_recursive(), optional_api_destroy(), safe_vector_cleanup(), softmix_bridge_leave(), softmix_bridge_stream_topology_changed(), and stasis_cleanup().
#define AST_VECTOR_GET | ( | vec, | |
idx | |||
) |
Get an element from a vector.
vec | Vector to query. |
idx | Index of the element to get. |
Definition at line 680 of file vector.h.
Referenced by __ast_sorcery_object_type_remove_wizard(), ast_bridge_channel_queue_frame(), ast_cli_completion_vector(), ast_context_remove_include2(), ast_context_remove_switch2(), ast_format_cap_append_from_cap(), ast_format_cap_empty(), ast_format_cap_get_best_by_type(), ast_format_cap_get_compatible(), ast_format_cap_get_format(), ast_format_cap_has_type(), ast_format_cap_iscompatible(), ast_format_cap_replace_from_cap(), ast_log_backtrace(), ast_msg_has_destination(), ast_pjproject_get_buildopt(), ast_refresh_resource(), ast_rtp_codecs_find_payload_code(), ast_rtp_codecs_get_payload(), ast_rtp_codecs_get_payload_format(), ast_rtp_codecs_get_stream_type(), ast_rtp_codecs_payload_code_sample_rate(), ast_rtp_codecs_payload_code_tx_sample_rate(), ast_rtp_codecs_payload_formats(), ast_rtp_codecs_payload_replace_format(), ast_rtp_codecs_payloads_copy(), ast_rtp_codecs_payloads_destroy(), ast_rtp_codecs_payloads_set_m_type(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_codecs_payloads_unset(), ast_rtp_codecs_payloads_xover(), ast_rtp_instance_extmap_get_id(), ast_rtp_instance_extmap_negotiate(), ast_sip_add_security_headers(), ast_sip_security_mechanisms_to_str(), ast_sip_security_mechanisms_vector_copy(), ast_sip_security_mechanisms_vector_destroy(), ast_sorcery_create(), ast_sorcery_delete(), ast_sorcery_get_wizard_mapping(), ast_sorcery_is_stale(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), ast_sorcery_retrieve_by_prefix(), ast_sorcery_retrieve_by_regex(), ast_sorcery_update(), ast_stream_topology_clone(), ast_stream_topology_create_resolved(), ast_stream_topology_del_stream(), ast_stream_topology_get_active_count(), ast_stream_topology_get_first_stream_by_type(), ast_stream_topology_get_formats_by_type(), ast_stream_topology_get_stream(), ast_stream_topology_set_stream(), ast_stream_topology_to_str(), ast_taskprocessor_get_subsystem_alert(), ast_update_module_list_data(), ast_xml_query_with_namespaces(), auto_unload_resource(), build_expression_queue(), chan_pjsip_indicate(), create_outgoing_sdp_stream(), display_entry_list(), enable_rtp_extension(), evaluate_history_entry(), event_session_shutdown(), event_session_update_websocket(), filter_history(), find_wizard(), format_cap_destroy(), load_modules(), module_deps_missing_recursive(), prometheus_callback_unregister(), prometheus_metric_register(), prometheus_metric_unregister(), softmix_bridge_stream_topology_changed(), stasis_app_control_play_uri(), stasis_app_playback_to_json(), stasis_cache_entry_get_remote(), stasis_forward_all(), stasis_state_add_subscriber(), stasis_subscription_is_subscribed(), subscription_invoke(), t38_reinvite_response_cb(), topic_add_subscription(), and verify_user_event_fields().
#define AST_VECTOR_GET_ADDR | ( | vec, | |
idx | |||
) |
Get an address of element in a vector.
vec | Vector to query. |
idx | Index of the element to get address of. |
Definition at line 668 of file vector.h.
Referenced by __rtp_find_instance_by_ssrc(), ast_dns_query_set_get(), ast_dns_query_set_resolve_async(), ast_dns_query_set_resolve_cancel(), ast_format_cap_get_compatible_format(), ast_format_cap_get_format_framing(), ast_format_cap_iscompatible_format(), ast_format_cap_remove(), ast_format_cap_remove_by_type(), ast_rtp_instance_extmap_get_direction(), ast_rtp_instance_extmap_get_extension(), ast_rtp_remote_address_set(), ast_rtp_set_remote_ssrc(), chan_pjsip_read_stream(), dns_query_set_destroy(), format_cap_destroy(), and rtp_find_rtcp_fd_position().
#define AST_VECTOR_GET_CMP | ( | vec, | |
value, | |||
cmp | |||
) |
Get an element from a vector that matches the given comparison.
vec | Vector to get from. |
value | Value to pass into comparator. |
cmp | Comparator function/macros (called as cmp(elem, value) ) |
Definition at line 731 of file vector.h.
Referenced by __ast_sorcery_object_type_insert_wizard(), ast_rtp_read(), ast_vector_string_split(), get_api(), graceful_unload_possible(), and module_deps_missing_recursive().
#define AST_VECTOR_GET_INDEX | ( | vec, | |
value, | |||
cmp | |||
) | AST_VECTOR_GET_INDEX_NTH(vec, 1, value, cmp) |
Get the 1st index from a vector that matches the given comparison.
vec | Vector to get from. |
value | Value to pass into comparator. |
cmp | Comparator function/macros (called as cmp(elem, value) ) |
Definition at line 719 of file vector.h.
Referenced by ast_taskprocessor_get_subsystem_alert().
#define AST_VECTOR_GET_INDEX_NTH | ( | vec, | |
nth, | |||
value, | |||
cmp | |||
) |
Get the nth index from a vector that matches the given comparison.
vec | Vector to get from. |
nth | The nth index to find |
value | Value to pass into comparator. |
cmp | Comparator function/macros (called as cmp(elem, value) ) |
Definition at line 696 of file vector.h.
Referenced by ast_stream_topology_map(), and softmix_bridge_stream_topology_changed().
#define AST_VECTOR_INIT | ( | vec, | |
size | |||
) |
Initialize a vector.
If size is 0, then no space will be allocated until the vector is appended to.
vec | Vector to initialize. |
size | Initial size of the vector. |
0 | on success. |
Non-zero | on failure. |
Definition at line 113 of file vector.h.
Referenced by __ast_string_field_init(), ast_add_hint(), ast_builtins_init(), ast_context_find_or_create(), ast_dns_query_set_create(), ast_dns_txt_get_strings(), ast_msg_init(), ast_multi_object_blob_create(), ast_refer_init(), ast_refresh_resource(), ast_rtp_codecs_payloads_initialize(), ast_rtp_instance_new(), ast_rtp_new(), ast_rtp_prop_set(), ast_sip_security_mechanism_vector_init(), ast_stream_topology_alloc(), ast_stream_topology_map(), build_expression_queue(), control_create(), create_outgoing_sdp_stream(), evaluate_history_entry(), event_session_alloc(), filter_history(), format_cap_init(), internal_stasis_subscribe(), load_modules(), load_resource_list(), messaging_init(), module_deps_missing_recursive(), softmix_bridge_create(), softmix_bridge_stream_topology_changed(), stasis_init(), stasis_topic_create_with_detail(), and transport_state_callback().
#define AST_VECTOR_INSERT_AT | ( | vec, | |
idx, | |||
elem | |||
) |
Insert an element at a specific position in a vector, growing the vector if needed.
vec | Vector to insert into. |
idx | Position to insert at. |
elem | Element to insert. |
0 | on success. |
Non-zero | on failure. |
Definition at line 338 of file vector.h.
Referenced by __ast_sorcery_object_type_insert_wizard(), ast_cli_completion_vector(), graceful_unload_possible(), and prometheus_metric_unregister().
#define AST_VECTOR_MATCH_ALL | ( | element | ) | (CMP_MATCH) |
Default callback for AST_VECTOR_CALLBACK()
element | Element to compare against |
CMP_MATCH | always. |
#define AST_VECTOR_MAX_SIZE | ( | vec | ) | (vec)->max |
#define AST_VECTOR_PTR_FREE | ( | vec | ) |
Deallocates this vector pointer.
If any code to free the elements of this vector need to be run, that should be done prior to this call.
vec | Pointer to a malloc'd vector structure. |
Definition at line 189 of file vector.h.
Referenced by ast_cli_completion_matches(), ast_cli_completion_vector(), ast_dns_txt_free_strings(), and filter_history().
#define AST_VECTOR_REMOVE | ( | vec, | |
idx, | |||
preserve_ordered | |||
) |
Remove an element from a vector by index.
Note that elements in the vector may be reordered, so that the remove can happen in constant time.
vec | Vector to remove from. |
idx | Index of the element to remove. |
preserve_ordered | Preserve the vector order. |
Definition at line 412 of file vector.h.
Referenced by ast_cli_completion_vector(), build_expression_queue(), evaluate_history_entry(), module_deps_missing_recursive(), prometheus_callback_unregister(), and prometheus_metric_unregister().
#define AST_VECTOR_REMOVE_ALL_CMP_ORDERED | ( | vec, | |
value, | |||
cmp, | |||
cleanup | |||
) |
Remove all elements from a vector that matches the given comparison while maintaining order.
vec | Vector to remove from. |
value | Value to pass into comparator. |
cmp | Comparator function/macros (called as cmp(elem, value) ) |
cleanup | How to cleanup a removed element macro/function. |
#define AST_VECTOR_REMOVE_ALL_CMP_UNORDERED | ( | vec, | |
value, | |||
cmp, | |||
cleanup | |||
) |
Remove all elements from a vector that matches the given comparison.
vec | Vector to remove from. |
value | Value to pass into comparator. |
cmp | Comparator function/macros (called as cmp(elem, value) ) |
cleanup | How to cleanup a removed element macro/function. |
#define AST_VECTOR_REMOVE_CMP_ORDERED | ( | vec, | |
value, | |||
cmp, | |||
cleanup | |||
) |
Remove an element from a vector that matches the given comparison while maintaining order.
vec | Vector to remove from. |
value | Value to pass into comparator. |
cmp | Comparator function/macros (called as cmp(elem, value) ) |
cleanup | How to cleanup a removed element macro/function. |
0 | if element was removed. |
Non-zero | if element was not in the vector. |
Definition at line 540 of file vector.h.
Referenced by __ast_sorcery_remove_wizard_mapping(), ast_format_cap_remove(), ast_format_cap_remove_by_type(), and ast_rtp_read().
#define AST_VECTOR_REMOVE_CMP_UNORDERED | ( | vec, | |
value, | |||
cmp, | |||
cleanup | |||
) |
Remove an element from a vector that matches the given comparison.
vec | Vector to remove from. |
value | Value to pass into comparator. |
cmp | Comparator function/macros (called as cmp(elem, value) ) |
cleanup | How to cleanup a removed element macro/function. |
0 | if element was removed. |
Non-zero | if element was not in the vector. |
Definition at line 488 of file vector.h.
Referenced by ast_msg_handler_unregister(), ast_msg_tech_unregister(), ast_refer_tech_unregister(), ast_rtp_bundle(), ast_rtp_destroy(), messaging_app_unsubscribe_endpoint(), and optional_api_destroy().
#define AST_VECTOR_REMOVE_ELEM_ORDERED | ( | vec, | |
elem, | |||
cleanup | |||
) |
Remove an element from a vector while maintaining order.
vec | Vector to remove from. |
elem | Element to remove |
cleanup | How to cleanup a removed element macro/function. |
0 | if element was removed. |
Non-zero | if element was not in the vector. |
#define AST_VECTOR_REMOVE_ELEM_UNORDERED | ( | vec, | |
elem, | |||
cleanup | |||
) |
Remove an element from a vector.
vec | Vector to remove from. |
elem | Element to remove |
cleanup | How to cleanup a removed element macro/function. |
0 | if element was removed. |
Non-zero | if element was not in the vector. |
Definition at line 583 of file vector.h.
Referenced by stasis_state_remove_observer().
#define AST_VECTOR_REMOVE_ORDERED | ( | vec, | |
idx | |||
) | AST_VECTOR_REMOVE(vec, idx, 1) |
Remove an element from a vector by index while maintaining order.
vec | Vector to remove from. |
idx | Index of the element to remove. |
Definition at line 448 of file vector.h.
Referenced by __ast_sorcery_object_type_remove_wizard(), ast_context_remove_include2(), ast_context_remove_switch2(), and ast_stream_topology_del_stream().
#define AST_VECTOR_REMOVE_UNORDERED | ( | vec, | |
idx | |||
) | AST_VECTOR_REMOVE(vec, idx, 0) |
Remove an element from an unordered vector by index.
Note that elements in the vector may be reordered, so that the remove can happen in constant time.
vec | Vector to remove from. |
idx | Index of the element to remove. |
Definition at line 438 of file vector.h.
Referenced by clear_result_states().
#define AST_VECTOR_REPLACE | ( | vec, | |
idx, | |||
elem | |||
) |
Replace an element at a specific position in a vector, growing the vector if needed.
vec | Vector to replace into. |
idx | Position to replace. |
elem | Element to replace. |
0 | on success. |
Non-zero | on failure. |
Definition at line 284 of file vector.h.
Referenced by ast_channel_fd_add(), ast_rtp_codecs_payload_replace_format(), ast_rtp_codecs_payloads_copy(), ast_rtp_codecs_payloads_set_m_type(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_codecs_payloads_unset(), ast_rtp_instance_extmap_clear(), ast_rtp_instance_extmap_enable(), ast_rtp_instance_extmap_negotiate(), ast_stream_topology_map(), ast_stream_topology_set_stream(), map_source_to_destinations(), remb_enable_collection(), softmix_bridge_stream_topology_changed(), stasis_subscription_accept_message_type(), stasis_subscription_decline_message_type(), and verify_user_event_fields().
#define AST_VECTOR_RESET | ( | vec, | |
cleanup | |||
) |
Reset vector.
vec | Vector to reset. |
cleanup | A cleanup callback or AST_VECTOR_ELEM_CLEANUP_NOOP. |
Definition at line 625 of file vector.h.
Referenced by ast_rtp_read(), clear_history_entries(), control_move_cleanup(), event_session_update_websocket(), filter_history(), safe_vector_cleanup(), and softmix_bridge_stream_topology_changed().
#define AST_VECTOR_RW | ( | name, | |
type | |||
) |
#define AST_VECTOR_RW_FREE | ( | vec | ) |
Deallocates this locked vector.
If any code to free the elements of this vector need to be run, that should be done prior to this call.
vec | Vector to deallocate. |
Definition at line 202 of file vector.h.
Referenced by sorcery_object_type_destructor().
#define AST_VECTOR_RW_INIT | ( | vec, | |
size | |||
) |
Initialize a vector with a read/write lock.
If size is 0, then no space will be allocated until the vector is appended to.
vec | Vector to initialize. |
size | Initial size of the vector. |
0 | on success. |
Non-zero | on failure. |
Definition at line 158 of file vector.h.
Referenced by ast_tps_init(), sorcery_object_type_alloc(), and stasis_state_manager_create().
#define AST_VECTOR_RW_PTR_FREE | ( | vec | ) |
Deallocates this locked vector pointer.
If any code to free the elements of this vector need to be run, that should be done prior to this call.
vec | Pointer to a malloc'd vector structure. |
#define AST_VECTOR_RW_RDLOCK | ( | vec | ) | ast_rwlock_rdlock(&(vec)->lock) |
Obtain read lock on vector.
vec | Vector to operate on. |
0 | if success |
Non-zero | if error |
Definition at line 877 of file vector.h.
Referenced by ast_sorcery_create(), ast_sorcery_delete(), ast_sorcery_is_stale(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), ast_sorcery_retrieve_by_prefix(), ast_sorcery_retrieve_by_regex(), ast_sorcery_update(), ast_taskprocessor_get_subsystem_alert(), find_wizard(), and stasis_state_add_subscriber().
#define AST_VECTOR_RW_RDLOCK_TIMED | ( | vec, | |
timespec | |||
) | ast_rwlock_timedrdlock(&(vec)->lock, timespec) |
#define AST_VECTOR_RW_RDLOCK_TRY | ( | vec | ) | ast_rwlock_tryrdlock(&(vec)->lock) |
#define AST_VECTOR_RW_UNLOCK | ( | vec | ) | ast_rwlock_unlock(&(vec)->lock) |
Unlock vector.
vec | Vector to operate on. |
0 | if success |
Non-zero | if error |
Definition at line 897 of file vector.h.
Referenced by __ast_sorcery_object_type_insert_wizard(), __ast_sorcery_object_type_remove_wizard(), __ast_sorcery_remove_wizard_mapping(), ast_sorcery_create(), ast_sorcery_delete(), ast_sorcery_is_stale(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), ast_sorcery_retrieve_by_prefix(), ast_sorcery_retrieve_by_regex(), ast_sorcery_update(), ast_taskprocessor_get_subsystem_alert(), find_wizard(), sorcery_object_type_destructor(), stasis_state_add_observer(), stasis_state_add_subscriber(), stasis_state_remove_observer(), and wizard_mapped_observer().
#define AST_VECTOR_RW_WRLOCK | ( | vec | ) | ast_rwlock_wrlock(&(vec)->lock) |
Obtain write lock on vector.
vec | Vector to operate on. |
0 | if success |
Non-zero | if error |
Definition at line 887 of file vector.h.
Referenced by __ast_sorcery_object_type_insert_wizard(), __ast_sorcery_object_type_remove_wizard(), __ast_sorcery_remove_wizard_mapping(), sorcery_object_type_destructor(), stasis_state_add_observer(), stasis_state_remove_observer(), and wizard_mapped_observer().
#define AST_VECTOR_RW_WRLOCK_TIMED | ( | vec, | |
timespec | |||
) | ast_rwlock_timedwrlock(&(vec)->lock, timespec) |
#define AST_VECTOR_RW_WRLOCK_TRY | ( | vec | ) | ast_rwlock_trywrlock(&(vec)->lock) |
#define AST_VECTOR_SIZE | ( | vec | ) | (vec)->current |
Get the number of elements in a vector.
vec | Vector to query. |
Definition at line 609 of file vector.h.
Referenced by __ast_sorcery_object_type_insert_wizard(), __ast_sorcery_object_type_remove_wizard(), __rtp_find_instance_by_ssrc(), ast_bridge_channel_queue_frame(), ast_channel_fd_count(), ast_cli_completion_vector(), ast_dns_query_set_get(), ast_dns_query_set_num_queries(), ast_dns_query_set_resolve_async(), ast_dns_query_set_resolve_cancel(), ast_format_cap_append_from_cap(), ast_format_cap_count(), ast_format_cap_get_best_by_type(), ast_format_cap_get_compatible(), ast_format_cap_get_compatible_format(), ast_format_cap_get_format(), ast_format_cap_get_format_framing(), ast_format_cap_has_type(), ast_format_cap_identical(), ast_format_cap_iscompatible(), ast_format_cap_iscompatible_format(), ast_format_cap_remove(), ast_format_cap_remove_by_type(), ast_format_cap_replace_from_cap(), ast_log_backtrace(), ast_msg_has_destination(), ast_pjproject_get_buildopt(), ast_refresh_resource(), ast_rtp_codecs_find_payload_code(), ast_rtp_codecs_get_payload(), ast_rtp_codecs_get_payload_format(), ast_rtp_codecs_get_stream_type(), ast_rtp_codecs_payload_code_sample_rate(), ast_rtp_codecs_payload_code_tx_sample_rate(), ast_rtp_codecs_payload_formats(), ast_rtp_codecs_payload_replace_format(), ast_rtp_codecs_payloads_copy(), ast_rtp_codecs_payloads_destroy(), ast_rtp_codecs_payloads_set_m_type(), ast_rtp_codecs_payloads_set_rtpmap_type_rate(), ast_rtp_codecs_payloads_unset(), ast_rtp_codecs_payloads_xover(), ast_rtp_instance_extmap_clear(), ast_rtp_instance_extmap_count(), ast_rtp_instance_extmap_enable(), ast_rtp_instance_extmap_get_direction(), ast_rtp_instance_extmap_get_extension(), ast_rtp_instance_extmap_get_id(), ast_rtp_instance_extmap_negotiate(), ast_rtp_read(), ast_rtp_remote_address_set(), ast_rtp_set_remote_ssrc(), ast_sip_add_security_headers(), ast_sip_security_mechanisms_to_str(), ast_sip_security_mechanisms_vector_copy(), ast_sip_security_mechanisms_vector_destroy(), ast_sorcery_create(), ast_sorcery_delete(), ast_sorcery_get_wizard_mapping(), ast_sorcery_get_wizard_mapping_count(), ast_sorcery_is_stale(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), ast_sorcery_retrieve_by_prefix(), ast_sorcery_retrieve_by_regex(), ast_sorcery_update(), ast_stream_topology_append_stream(), ast_stream_topology_clone(), ast_stream_topology_create_resolved(), ast_stream_topology_del_stream(), ast_stream_topology_get_active_count(), ast_stream_topology_get_count(), ast_stream_topology_get_first_stream_by_type(), ast_stream_topology_get_formats_by_type(), ast_stream_topology_map(), ast_stream_topology_set_stream(), ast_stream_topology_to_str(), ast_update_module_list_data(), ast_xml_query_with_namespaces(), auto_unload_resource(), build_expression_queue(), chan_pjsip_indicate(), chan_pjsip_read_stream(), clear_result_states(), control_next_app_args_size(), create_outgoing_sdp_stream(), display_entry_list(), dns_query_set_callback(), dns_query_set_destroy(), enable_rtp_extension(), evaluate_history_entry(), event_session_dtor(), event_session_shutdown(), event_session_update_websocket(), filter_history(), find_wizard(), format_cap_destroy(), load_modules(), messaging_app_unsubscribe_endpoint(), module_deps_missing_recursive(), optional_api_set_impl(), prometheus_callback_unregister(), prometheus_metric_register(), prometheus_metric_registered_count(), prometheus_metric_unregister(), rtp_find_rtcp_fd_position(), softmix_bridge_stream_topology_changed(), stasis_app_playback_to_json(), stasis_cache_entry_get_remote(), stasis_forward_all(), stasis_state_add_subscriber(), stasis_subscription_decline_message_type(), stasis_subscription_is_subscribed(), stasis_topic_subscribers(), subscription_invoke(), t38_reinvite_response_cb(), topic_add_subscription(), and verify_user_event_fields().
#define AST_VECTOR_SORT | ( | vec, | |
cmp | |||
) |
#define AST_VECTOR_STEAL_ELEMENTS | ( | vec | ) |
Steal the elements from a vector and reinitialize.
vec | Vector to operate on. |
This allows you to use vector.h to construct a list and use the data as a bare array.
Definition at line 140 of file vector.h.
Referenced by ast_cli_completion_matches(), and control_next_app_args().
Options to override default processing of ast_vector_string_split.
Enumerator | |
---|---|
AST_VECTOR_STRING_SPLIT_NO_TRIM |
Do not trim whitespace from values. |
AST_VECTOR_STRING_SPLIT_ALLOW_EMPTY |
Append empty strings to the vector. |
Definition at line 59 of file vector.h.
int ast_vector_string_split | ( | struct ast_vector_string * | dest, |
const char * | input, | ||
const char * | delim, | ||
int | flags, | ||
int(*)(const char *s1, const char *s2) | excludes_cmp | ||
) |
Append a string vector by splitting a string.
dest | Pointer to an initialized vector. |
input | String buffer to split. |
delim | String delimeter passed to strsep. |
flags | Processing options defined by ast_vector_string_split_flags. |
excludes_cmp | NULL or a function like strcmp to exclude duplicate strings. |
0 | Success |
-1 | Failure |
Definition at line 392 of file strings.c.
References ast_strdup, ast_strdupa, ast_strip(), AST_VECTOR_APPEND, AST_VECTOR_GET_CMP, AST_VECTOR_STRING_SPLIT_ALLOW_EMPTY, and AST_VECTOR_STRING_SPLIT_NO_TRIM.