\param hash the hash to delete from
\param key the key from which to delete the data
\param mutex optional mutex to lock
- \return SWITCH_STATUS_SUCCESS if the data is deleted
+ \return a pointer to the deleted data
*/
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_mutex_t *mutex);
+SWITCH_DECLARE(void *) switch_core_hash_delete_locked(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_mutex_t *mutex);
/*!
\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
\param mutex optional rwlock to wrlock
- \return SWITCH_STATUS_SUCCESS if the data is deleted
+ \return a pointer to the deleted data
*/
-SWITCH_DECLARE(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);
+SWITCH_DECLARE(void *) switch_core_hash_delete_wrlock(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_thread_rwlock_t *rwlock);
/*!
\brief Delete data from a hash based on callback function
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_locked(switch_hash_t *hash, const char *key, const void *data, switch_mutex_t *mutex)
{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
if (mutex) {
switch_mutex_lock(mutex);
}
- switch_core_hash_insert(hash, key, data);
+ status = switch_core_hash_insert(hash, key, data);
if (mutex) {
switch_mutex_unlock(mutex);
}
- return SWITCH_STATUS_SUCCESS;
+ return status;
}
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_wrlock(switch_hash_t *hash, const char *key, const void *data, switch_thread_rwlock_t *rwlock)
{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
if (rwlock) {
switch_thread_rwlock_wrlock(rwlock);
}
- switch_core_hash_insert(hash, key, data);
+ status = switch_core_hash_insert(hash, key, data);
if (rwlock) {
switch_thread_rwlock_unlock(rwlock);
}
- return SWITCH_STATUS_SUCCESS;
+ return status;
}
SWITCH_DECLARE(void *) switch_core_hash_delete(switch_hash_t *hash, const char *key)
return switch_hashtable_remove(hash, (void *)key);
}
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(switch_hash_t *hash, const char *key, switch_mutex_t *mutex)
+SWITCH_DECLARE(void *) switch_core_hash_delete_locked(switch_hash_t *hash, const char *key, switch_mutex_t *mutex)
{
+ void *ret = NULL;
+
if (mutex) {
switch_mutex_lock(mutex);
}
switch_mutex_unlock(mutex);
}
- return SWITCH_STATUS_SUCCESS;
+ return ret;
}
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_wrlock(switch_hash_t *hash, const char *key, switch_thread_rwlock_t *rwlock)
+SWITCH_DECLARE(void *) switch_core_hash_delete_wrlock(switch_hash_t *hash, const char *key, switch_thread_rwlock_t *rwlock)
{
+ void *ret = NULL;
+
if (rwlock) {
switch_thread_rwlock_wrlock(rwlock);
}
- switch_core_hash_delete(hash, key);
+ ret = switch_core_hash_delete(hash, key);
if (rwlock) {
switch_thread_rwlock_unlock(rwlock);
}
- return SWITCH_STATUS_SUCCESS;
+ return ret;
}
SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(switch_hash_t *hash, switch_hash_delete_callback_t callback, void *pData) {