mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-30 07:04:17 +00:00
[Core] Add new switch_core_hash_insert_dup_auto_free() API
This commit is contained in:
1 parent
0b0f5fff65
commit
58abf91d1d
3 files changed
+32
-10
No files matched your search
@@ -85,6 +85,23 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_auto_free(switch_hash_t
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_core_hash_insert_dup_auto_free(switch_hash_t *hash, const char *key, const char *str)
|
||||
{
|
||||
char *dkey = strdup(key);
|
||||
char *dup = strdup(str);
|
||||
|
||||
assert(dup);
|
||||
|
||||
if (switch_hashtable_insert_destructor(hash, dkey, (void *)dup, HASHTABLE_FLAG_FREE_KEY | HASHTABLE_FLAG_FREE_VALUE | HASHTABLE_DUP_CHECK, NULL)) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
switch_safe_free(dup);
|
||||
switch_safe_free(dkey);
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(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) {
|
||||
char *dkey;
|
||||
void *data;
|
||||
|
||||
Reference in new issue
Block a user