Hash Functions
[Core Library]

Collaboration diagram for Hash Functions:

Defines

#define switch_core_hash_init(_hash, _pool)   switch_core_hash_init_case(_hash, _pool, SWITCH_TRUE)
#define switch_core_hash_init_nocase(_hash, _pool)   switch_core_hash_init_case(_hash, _pool, SWITCH_FALSE)

Functions

switch_status_t switch_core_hash_init_case (_Out_ switch_hash_t **hash, _In_ switch_memory_pool_t *pool, switch_bool_t case_sensitive)
 Initialize a hash table.
switch_status_t switch_core_hash_destroy (_Inout_ switch_hash_t **hash)
 Destroy an existing hash table.
switch_status_t switch_core_hash_insert (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data)
 Insert data into a hash.
switch_status_t switch_core_hash_insert_locked (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ const void *data, _In_opt_ switch_mutex_t *mutex)
 Insert data into a hash.
switch_status_t switch_core_hash_insert_wrlock (switch_hash_t *hash, const char *key, const void *data, switch_thread_rwlock_t *rwlock)
 Retrieve data from a given hash.
switch_status_t switch_core_hash_delete (_In_ switch_hash_t *hash, _In_z_ const char *key)
 Delete data from a hash based on desired key.
switch_status_t switch_core_hash_delete_locked (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_mutex_t *mutex)
 Delete data from a hash based on desired key.
switch_status_t switch_core_hash_delete_wrlock (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_thread_rwlock_t *rwlock)
 Delete data from a hash based on desired key.
switch_status_t switch_core_hash_delete_multi (_In_ switch_hash_t *hash, _In_ switch_hash_delete_callback_t callback, _In_opt_ void *pData)
 Delete data from a hash based on callback function.
void * switch_core_hash_find (_In_ switch_hash_t *hash, _In_z_ const char *key)
 Retrieve data from a given hash.
void * switch_core_hash_find_locked (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_mutex_t *mutex)
 Retrieve data from a given hash.
void * switch_core_hash_find_rdlock (_In_ switch_hash_t *hash, _In_z_ const char *key, _In_ switch_thread_rwlock_t *rwlock)
 Retrieve data from a given hash.
switch_hash_index_tswitch_hash_first (char *deprecate_me, _In_ switch_hash_t *hash)
 Gets the first element of a hashtable.
switch_hash_index_tswitch_hash_next (_In_ switch_hash_index_t *hi)
 Gets the next element of a hashtable.
void switch_hash_this (_In_ switch_hash_index_t *hi, _Out_opt_ptrdiff_cap_(klen) const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val)
 Gets the key and value of the current hash element.


Define Documentation

#define switch_core_hash_init ( _hash,
_pool   )     switch_core_hash_init_case(_hash, _pool, SWITCH_TRUE)

Definition at line 1217 of file switch_core.h.

Referenced by switch_channel_alloc(), switch_channel_set_app_flag_key(), switch_console_init(), switch_core_init(), switch_core_session_init(), switch_event_init(), switch_ivr_digit_stream_parser_new(), switch_ivr_dmachine_create(), switch_load_network_lists(), switch_load_timezones(), switch_loadable_module_init(), switch_rtp_init(), and switch_xml_init().

#define switch_core_hash_init_nocase ( _hash,
_pool   )     switch_core_hash_init_case(_hash, _pool, SWITCH_FALSE)

Definition at line 1218 of file switch_core.h.

Referenced by switch_loadable_module_init().


Function Documentation

switch_status_t switch_core_hash_delete ( _In_ switch_hash_t hash,
_In_z_ const char *  key 
)

Delete data from a hash based on desired key.

Parameters:
hash the hash to delete from
key the key from which to delete the data
Returns:
SWITCH_STATUS_SUCCESS if the data is deleted

Referenced by switch_core_hash_delete_multi(), switch_core_session_perform_destroy(), switch_core_session_set_uuid(), switch_event_free_subclass_detailed(), switch_ivr_digit_stream_parser_del_event(), switch_ivr_dmachine_clear_realm(), switch_loadable_module_unload_module(), switch_loadable_module_unprocess(), switch_xml_clear_user_cache(), and switch_xml_user_cache().

switch_status_t switch_core_hash_delete_locked ( _In_ switch_hash_t hash,
_In_z_ const char *  key,
_In_opt_ switch_mutex_t mutex 
)

Delete data from a hash based on desired key.

Parameters:
hash the hash to delete from
key the key from which to delete the data
mutex optional mutex to lock
Returns:
SWITCH_STATUS_SUCCESS if the data is deleted

switch_status_t switch_core_hash_delete_multi ( _In_ switch_hash_t hash,
_In_ switch_hash_delete_callback_t  callback,
_In_opt_ void *  pData 
)

Delete data from a hash based on callback function.

Parameters:
hash the hash to delete from
callback the function to call which returns SWITCH_TRUE to delete, SWITCH_FALSE to preserve
Returns:
SWITCH_STATUS_SUCCESS if any data is deleted

switch_status_t switch_core_hash_delete_wrlock ( _In_ switch_hash_t hash,
_In_z_ const char *  key,
_In_opt_ switch_thread_rwlock_t rwlock 
)

Delete data from a hash based on desired key.

Parameters:
hash the hash to delete from
key the key from which to delete the data
mutex optional rwlock to wrlock
Returns:
SWITCH_STATUS_SUCCESS if the data is deleted

switch_status_t switch_core_hash_destroy ( _Inout_ switch_hash_t **  hash  ) 

Destroy an existing hash table.

Parameters:
hash the hash to destroy
Returns:
SWITCH_STATUS_SUCCESS if the hash is destroyed

Referenced by switch_channel_uninit(), switch_console_shutdown(), switch_core_destroy(), switch_core_session_uninit(), switch_event_shutdown(), switch_ivr_digit_stream_parser_destroy(), switch_ivr_dmachine_destroy(), switch_load_network_lists(), switch_load_timezones(), switch_loadable_module_shutdown(), SWITCH_MODULE_SHUTDOWN_FUNCTION(), switch_rtp_shutdown(), and switch_xml_destroy().

void* switch_core_hash_find ( _In_ switch_hash_t hash,
_In_z_ const char *  key 
)

Retrieve data from a given hash.

Parameters:
hash the hash to retrieve from
key the key to retrieve
Returns:
a pointer to the data held in the key

Referenced by switch_channel_clear_app_flag_key(), switch_channel_set_app_flag_key(), switch_channel_test_app_flag_key(), switch_check_network_list_ip_token(), switch_console_run_complete_func(), switch_core_mime_add_type(), switch_core_mime_ext2type(), switch_core_session_event_send(), switch_core_session_force_locate(), switch_core_session_locate(), switch_core_session_message_send(), switch_core_session_request_uuid(), switch_core_session_set_uuid(), switch_default_ptime(), switch_event_bind_removable(), switch_event_build_param_string(), switch_event_free_subclass_detailed(), switch_event_reserve_subclass_detailed(), switch_ivr_digit_stream_parser_feed(), switch_ivr_dmachine_bind(), switch_ivr_dmachine_clear_realm(), switch_ivr_dmachine_set_realm(), switch_loadable_module_exists(), switch_loadable_module_get_codec_interface(), switch_loadable_module_get_endpoint_interface(), switch_loadable_module_process(), switch_loadable_module_unload_module(), switch_loadable_module_unprocess(), switch_lookup_timezone(), switch_rtp_release_port(), switch_rtp_request_port(), switch_xml_clear_user_cache(), switch_xml_locate_user_cache(), and switch_xml_user_cache().

void* switch_core_hash_find_locked ( _In_ switch_hash_t hash,
_In_z_ const char *  key,
_In_ switch_mutex_t mutex 
)

Retrieve data from a given hash.

Parameters:
hash the hash to retrieve from
key the key to retrieve
mutex optional mutex to lock
Returns:
a pointer to the data held in the key

Referenced by switch_channel_get_private(), switch_channel_get_private_partner(), switch_loadable_module_get_management_interface(), switch_loadable_module_get_say_interface(), and switch_loadable_module_load_module_ex().

void* switch_core_hash_find_rdlock ( _In_ switch_hash_t hash,
_In_z_ const char *  key,
_In_ switch_thread_rwlock_t rwlock 
)

Retrieve data from a given hash.

Parameters:
hash the hash to retrieve from
key the key to retrieve
mutex optional rwlock to rdlock
Returns:
a pointer to the data held in the key

switch_status_t switch_core_hash_init_case ( _Out_ switch_hash_t **  hash,
_In_ switch_memory_pool_t pool,
switch_bool_t  case_sensitive 
)

Initialize a hash table.

Parameters:
hash a NULL pointer to a hash table to aim at the new hash
pool the pool to use for the new hash
Returns:
SWITCH_STATUS_SUCCESS if the hash is created

Referenced by switch_core_init().

switch_status_t switch_core_hash_insert ( _In_ switch_hash_t hash,
_In_z_ const char *  key,
_In_opt_ const void *  data 
)

Insert data into a hash.

Parameters:
hash the hash to add data to
key the name of the key to add the data to
data the data to add
Returns:
SWITCH_STATUS_SUCCESS if the data is added
Note:
the string key must be a constant or a dynamic string

Referenced by switch_channel_set_app_flag_key(), switch_console_add_complete_func(), switch_console_del_complete_func(), switch_core_mime_add_type(), switch_core_session_request_uuid(), switch_core_session_set_uuid(), switch_event_reserve_subclass_detailed(), switch_ivr_digit_stream_parser_set_event(), switch_ivr_dmachine_bind(), switch_load_core_config(), switch_load_network_lists(), switch_load_timezones(), switch_loadable_module_process(), switch_rtp_request_port(), and switch_xml_user_cache().

switch_status_t switch_core_hash_insert_locked ( _In_ switch_hash_t hash,
_In_z_ const char *  key,
_In_opt_ const void *  data,
_In_opt_ switch_mutex_t mutex 
)

Insert data into a hash.

Parameters:
hash the hash to add data to
key the name of the key to add the data to
data the data to add
mutex optional mutex to lock
Returns:
SWITCH_STATUS_SUCCESS if the data is added
Note:
the string key must be a constant or a dynamic string

Referenced by switch_channel_set_private(), and switch_loadable_module_unload_module().

switch_status_t switch_core_hash_insert_wrlock ( switch_hash_t hash,
const char *  key,
const void *  data,
switch_thread_rwlock_t rwlock 
)

Retrieve data from a given hash.

Parameters:
hash the hash to retrieve from
key the key to retrieve
mutex optional rwlock to wrlock
Returns:
a pointer to the data held in the key

Definition at line 99 of file switch_core_hash.c.

References SWITCH_STATUS_SUCCESS, switch_thread_rwlock_unlock(), and switch_thread_rwlock_wrlock().

00100 {
00101         if (rwlock) {
00102                 switch_thread_rwlock_wrlock(rwlock);
00103         }
00104 
00105         sqlite3HashInsert(&hash->table, key, (int) strlen(key) + 1, (void *) data);
00106 
00107         if (rwlock) {
00108                 switch_thread_rwlock_unlock(rwlock);
00109         }
00110 
00111         return SWITCH_STATUS_SUCCESS;
00112 }

switch_hash_index_t* switch_hash_first ( char *  deprecate_me,
_In_ switch_hash_t hash 
)

Gets the first element of a hashtable.

Parameters:
deprecate_me [deprecated] NULL
hash the hashtable to use
Returns:
The element, or NULL if it wasn't found

Referenced by do_chat_send(), switch_core_hash_delete_multi(), switch_core_mime_index(), switch_core_session_hupall(), switch_core_session_hupall_endpoint(), switch_core_session_hupall_matching_var(), switch_event_shutdown(), switch_loadable_module_enumerate_loaded(), switch_loadable_module_get_codecs(), switch_loadable_module_runtime(), switch_loadable_module_shutdown(), switch_rtp_shutdown(), and switch_xml_clear_user_cache().

switch_hash_index_t* switch_hash_next ( _In_ switch_hash_index_t hi  ) 

Gets the next element of a hashtable.

Parameters:
hi The current element
Returns:
The next element, or NULL if there are no more

Referenced by do_chat_send(), switch_core_hash_delete_multi(), switch_core_session_hupall(), switch_core_session_hupall_endpoint(), switch_core_session_hupall_matching_var(), switch_event_shutdown(), switch_loadable_module_enumerate_loaded(), switch_loadable_module_get_codecs(), switch_loadable_module_runtime(), switch_loadable_module_shutdown(), and switch_rtp_shutdown().

void switch_hash_this ( _In_ switch_hash_index_t hi,
_Out_opt_ptrdiff_cap_(klen) const void **  key,
_Out_opt_ switch_ssize_t klen,
_Out_ void **  val 
)

Gets the key and value of the current hash element.

Parameters:
hi The current element
key [out] the key
klen [out] the key's size
val [out] the value

Referenced by do_chat_send(), switch_core_hash_delete_multi(), switch_core_session_hupall(), switch_core_session_hupall_endpoint(), switch_core_session_hupall_matching_var(), switch_event_shutdown(), switch_loadable_module_enumerate_loaded(), switch_loadable_module_get_codecs(), switch_loadable_module_runtime(), switch_loadable_module_shutdown(), switch_rtp_shutdown(), and switch_xml_clear_user_cache().


Generated on Wed May 16 04:00:18 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7