mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-15 05:48:33 +00:00
Avoid leaking memory while iterating hash tables
`switch_core_hash_first` allocates an iterator on each call that is never freed except when the hash table is empty. By using `switch_core_hash_first_iter` we allocate only one iterator, and that iterator is freed after the last item is processed.
This commit is contained in:
1 parent
75836b603f
commit
acb439ca03
4 files changed
+8
-8
No files matched your search
@@ -1091,7 +1091,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_directory_load)
|
||||
Macro expands to: switch_status_t mod_directory_shutdown() */
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_directory_shutdown)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
dir_profile_t *profile;
|
||||
void *val = NULL;
|
||||
const void *key;
|
||||
@@ -1100,7 +1100,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_directory_shutdown)
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
|
||||
while ((hi = switch_core_hash_first(globals.profile_hash))) {
|
||||
while ((hi = switch_core_hash_first_iter(globals.profile_hash, hi))) {
|
||||
switch_core_hash_this(hi, &key, &keylen, &val);
|
||||
profile = (dir_profile_t *) val;
|
||||
|
||||
|
||||
Reference in new issue
Block a user