]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8821 #resolve [Check for status of executed operation]
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 10 Feb 2016 20:55:13 +0000 (14:55 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 10 Feb 2016 20:55:20 +0000 (14:55 -0600)
src/include/switch_core.h
src/switch_core_hash.c

index 16669672e8f8faea579fad9c5f3cfcebf19e2f71..e9e50824361a06b48762373b41f93fdf5dda750e 100644 (file)
@@ -1443,18 +1443,18 @@ SWITCH_DECLARE(void *) switch_core_hash_delete(_In_ switch_hash_t *hash, _In_z_
   \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
index 29427013b0d3d06196818698a5b6da4e53201ca7..51fc53887c5f6a08b5b50102b0628e045065fa78 100644 (file)
@@ -66,32 +66,36 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_destructor(switch_hash_t
 
 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)
@@ -99,8 +103,10 @@ SWITCH_DECLARE(void *) switch_core_hash_delete(switch_hash_t *hash, const char *
        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);
        }
@@ -111,22 +117,24 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(switch_hash_t *ha
                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) {