mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-16 06:18:35 +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
@@ -152,7 +152,6 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
limit_redis_private_t *pvt = switch_channel_get_private(channel, "limit_redis");
|
||||
int val, uuid_val;
|
||||
switch_hash_index_t *hi;
|
||||
char *rediskey = NULL;
|
||||
char *uuid_rediskey = NULL;
|
||||
int status = SWITCH_STATUS_SUCCESS;
|
||||
@@ -171,8 +170,9 @@ SWITCH_LIMIT_RELEASE(limit_release_redis)
|
||||
|
||||
/* clear for uuid */
|
||||
if (realm == NULL && resource == NULL) {
|
||||
switch_hash_index_t *hi = NULL;
|
||||
/* Loop through the channel's hashtable which contains mapping to all the limit_redis_item_t referenced by that channel */
|
||||
while ((hi = switch_core_hash_first(pvt->hash))) {
|
||||
while ((hi = switch_core_hash_first_iter(pvt->hash, hi))) {
|
||||
void *p_val = NULL;
|
||||
const void *p_key;
|
||||
char *p_uuid_key = NULL;
|
||||
|
||||
Reference in new issue
Block a user