mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 04:31:50 +00:00
FS-7500: add switch_inthash variety of hash that can key on int
This commit is contained in:
@@ -1400,9 +1400,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_wrlock(switch_hash_t *ha
|
||||
\brief Delete data from a hash based on desired key
|
||||
\param hash the hash to delete from
|
||||
\param key the key from which to delete the data
|
||||
\return SWITCH_STATUS_SUCCESS if the data is deleted
|
||||
\return The value stored if the data is deleted otherwise NULL
|
||||
*/
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key);
|
||||
SWITCH_DECLARE(void *) switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_ const char *key);
|
||||
|
||||
/*!
|
||||
\brief Delete data from a hash based on desired key
|
||||
@@ -1491,6 +1491,11 @@ SWITCH_DECLARE(void) switch_core_hash_this(_In_ switch_hash_index_t *hi, _Out_op
|
||||
const void **key, _Out_opt_ switch_ssize_t *klen, _Out_ void **val);
|
||||
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_inthash_init(switch_inthash_t **hash);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_inthash_destroy(switch_inthash_t **hash);
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_inthash_insert(switch_inthash_t *hash, uint32_t key, const void *data);
|
||||
SWITCH_DECLARE(void *) switch_core_inthash_delete(switch_inthash_t *hash, uint32_t key);
|
||||
SWITCH_DECLARE(void *) switch_core_inthash_find(switch_inthash_t *hash, uint32_t key);
|
||||
|
||||
///\}
|
||||
|
||||
|
||||
@@ -197,6 +197,19 @@ SWITCH_DECLARE(switch_hashtable_iterator_t*) switch_hashtable_first_iter(switch_
|
||||
SWITCH_DECLARE(switch_hashtable_iterator_t*) switch_hashtable_next(switch_hashtable_iterator_t **iP);
|
||||
SWITCH_DECLARE(void) switch_hashtable_this(switch_hashtable_iterator_t *i, const void **key, switch_ssize_t *klen, void **val);
|
||||
|
||||
static inline uint32_t switch_hash_default_int(void *ky) {
|
||||
uint32_t x = *((uint32_t *)ky);
|
||||
x = ((x >> 16) ^ x) * 0x45d9f3b;
|
||||
x = ((x >> 16) ^ x) * 0x45d9f3b;
|
||||
x = ((x >> 16) ^ x);
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline int switch_hash_equalkeys_int(void *k1, void *k2)
|
||||
{
|
||||
return *(uint32_t *)k1 == *(uint32_t *)k2;
|
||||
}
|
||||
|
||||
static inline int switch_hash_equalkeys(void *k1, void *k2)
|
||||
{
|
||||
return strcmp((char *) k1, (char *) k2) ? 0 : 1;
|
||||
|
||||
@@ -735,6 +735,7 @@ typedef enum {
|
||||
SWITCH_RTP_FLAG_PLI,
|
||||
SWITCH_RTP_FLAG_RESET,
|
||||
SWITCH_RTP_FLAG_MUTE,
|
||||
SWITCH_RTP_FLAG_NACK,
|
||||
SWITCH_RTP_FLAG_INVALID
|
||||
} switch_rtp_flag_t;
|
||||
|
||||
@@ -2340,6 +2341,7 @@ typedef switch_xml_t(*switch_xml_search_function_t) (const char *section,
|
||||
struct switch_hashtable;
|
||||
struct switch_hashtable_iterator;
|
||||
typedef struct switch_hashtable switch_hash_t;
|
||||
typedef struct switch_hashtable switch_inthash_t;
|
||||
typedef struct switch_hashtable_iterator switch_hash_index_t;
|
||||
|
||||
struct switch_network_list;
|
||||
|
||||
Reference in New Issue
Block a user