60 size_t bytes_required = snprintf(NULL, 0,
"%p", data) + 1;
61 char *dkey = malloc(bytes_required);
62 size_t bytes_written = snprintf(dkey, bytes_required,
"%p", data);
64 if (bytes_written > 0 && bytes_written < bytes_required) {
77 char *dkey = strdup(key);
90 char *dkey = strdup(key);
91 char *dup = strdup(str);
109 if (!size)
return NULL;
129 char *dkey = strdup(key);
130 char *dup = strdup(str);
146 char *dkey = strdup(key);
248 if (!callback || callback(key, val, pData)) {
254 for (header = event->headers; header; header = header->
next) {
void * switch_core_hash_find_locked(switch_hash_t *hash, const char *key, switch_mutex_t *mutex)
switch_status_t switch_thread_rwlock_unlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_core_inthash_init(switch_inthash_t **hash)
switch_status_t switch_core_hash_init_case(switch_hash_t **hash, switch_bool_t case_sensitive)
switch_bool_t(* switch_hash_delete_callback_t)(_In_ const void *key, _In_ const void *val, _In_opt_ void *pData)
void * switch_hashtable_search(switch_hashtable_t *h, void *k)
switch_status_t switch_core_hash_destroy(switch_hash_t **hash)
void(* hashtable_destructor_t)(void *ptr)
void * switch_core_hash_find_rdlock(switch_hash_t *hash, const char *key, switch_thread_rwlock_t *rwlock)
Representation of an event.
void * switch_core_inthash_find(switch_inthash_t *hash, uint32_t key)
switch_status_t switch_core_hash_insert_auto_free(switch_hash_t *hash, const char *key, const void *data)
Insert data into a hash and set flags so the value is automatically freed on delete.
switch_status_t switch_core_hash_insert_locked(switch_hash_t *hash, const char *key, const void *data, switch_mutex_t *mutex)
#define switch_event_create_subclass(_e, _eid, _sn)
void switch_core_hash_this(switch_hash_index_t *hi, const void **key, switch_ssize_t *klen, void **val)
switch_hash_index_t * switch_core_hash_first_iter(switch_hash_t *hash, switch_hash_index_t *hi)
void * switch_core_hash_insert_alloc_destructor(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ size_t size, hashtable_destructor_t destructor)
Allocate memory and insert into a hash.
switch_status_t switch_mutex_unlock(switch_mutex_t *lock)
switch_status_t switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock)
switch_status_t switch_core_inthash_destroy(switch_inthash_t **hash)
switch_status_t switch_core_hash_insert_dup_auto_free(switch_hash_t *hash, const char *key, const char *str)
Insert strdup(str) into a hash and set flags so the value is automatically freed on delete...
static int switch_hash_equalkeys_ci(void *k1, void *k2)
switch_status_t switch_thread_rwlock_wrlock(switch_thread_rwlock_t *rwlock)
void * switch_core_hash_delete_wrlock(switch_hash_t *hash, const char *key, switch_thread_rwlock_t *rwlock)
void * switch_core_hash_find(switch_hash_t *hash, const char *key)
void * switch_core_inthash_delete(switch_inthash_t *hash, uint32_t key)
static uint32_t switch_hash_default_ci(void *ky)
switch_status_t switch_mutex_lock(switch_mutex_t *lock)
void switch_core_hash_this_val(switch_hash_index_t *hi, void *val)
switch_hashtable_iterator_t * switch_hashtable_first_iter(switch_hashtable_t *h, switch_hashtable_iterator_t *it)
int switch_hashtable_insert_destructor(switch_hashtable_t *h, void *k, void *v, hashtable_flag_t flags, hashtable_destructor_t destructor)
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_zmalloc(ptr, len)
switch_status_t switch_core_hash_insert_dup_destructor(switch_hash_t *hash, const char *key, const char *str, hashtable_destructor_t destructor)
switch_status_t switch_core_inthash_insert(switch_inthash_t *hash, uint32_t key, const void *data)
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
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.
static uint32_t switch_hash_default_int(void *ky)
const cJSON *const const cJSON_bool case_sensitive
void switch_hashtable_this_val(switch_hashtable_iterator_t *i, void *val)
switch_status_t switch_core_hash_delete_multi(switch_hash_t *hash, switch_hash_delete_callback_t callback, void *pData)
switch_status_t switch_core_hash_insert_pointer(switch_hash_t *hash, const void *data)
Insert data into a hash with an auto-generated key based on the data pointer.
struct fspr_thread_mutex_t switch_mutex_t
switch_thread_rwlock_t * rwlock
switch_status_t
Common return values.
switch_hashtable_iterator_t * switch_hashtable_next(switch_hashtable_iterator_t **iP)
#define switch_core_hash_insert(_h, _k, _d)
void switch_hashtable_destroy(switch_hashtable_t **h)
void * switch_core_hash_delete_locked(switch_hash_t *hash, const char *key, switch_mutex_t *mutex)
switch_status_t switch_create_hashtable(switch_hashtable_t **hp, unsigned int minsize, unsigned int(*hashfunction)(void *), int(*key_eq_fn)(void *, void *))
switch_status_t switch_core_hash_insert_destructor(switch_hash_t *hash, const char *key, const void *data, hashtable_destructor_t destructor)
void * switch_hashtable_remove(switch_hashtable_t *h, void *k)
static int switch_hash_equalkeys(void *k1, void *k2)
static uint32_t switch_hash_default(void *ky)
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_bool_t switch_core_hash_empty(switch_hash_t *hash)
tells if a hash is empty
void * switch_core_hash_delete(switch_hash_t *hash, const char *key)
struct fspr_thread_rwlock_t switch_thread_rwlock_t
#define switch_core_hash_first(_h)
void switch_hashtable_this(switch_hashtable_iterator_t *i, const void **key, switch_ssize_t *klen, void **val)
static int switch_hash_equalkeys_int(void *k1, void *k2)
switch_hash_index_t * switch_core_hash_next(switch_hash_index_t **hi)