diff options
author | Angelo Mantellini <manangel@cisco.com> | 2019-12-15 22:50:11 +0100 |
---|---|---|
committer | Angelo Mantellini <angelo.mantellini@cisco.com> | 2019-12-15 22:08:42 +0000 |
commit | a6325a7343cc971cfca45fb50e4d7a9b9b5a2982 (patch) | |
tree | fe846bdb9c24065f762ace775a3a2a1701f71afe /hicn-light/src/hicn/strategies | |
parent | 1439c2bc8a95e4b72dad45aafe4c1f7a581bcd5a (diff) |
[HICN-460] Check of parchashmap before creating iterator
Change-Id: I559e86e269026be601a5735f77bbcfac40f24694
Signed-off-by: Angelo Mantellini <angelo.mantellini@cisco.com>
Diffstat (limited to 'hicn-light/src/hicn/strategies')
-rw-r--r-- | hicn-light/src/hicn/strategies/loadBalancer.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/hicn-light/src/hicn/strategies/loadBalancer.c b/hicn-light/src/hicn/strategies/loadBalancer.c index e3f377791..35d64e763 100644 --- a/hicn-light/src/hicn/strategies/loadBalancer.c +++ b/hicn-light/src/hicn/strategies/loadBalancer.c @@ -344,22 +344,23 @@ static void _strategyLoadBalancer_ImplDestroy(StrategyImpl **strategyPtr) { StrategyImpl *impl = *strategyPtr; StrategyLoadBalancer *strategy = (StrategyLoadBalancer *)impl->context; + if (parcHashMap_Size(strategy->strategy_state) > 0) { + PARCIterator *it = parcHashMap_CreateKeyIterator(strategy->strategy_state); + while (parcIterator_HasNext(it)) { + PARCUnsigned *cid = parcIterator_Next(it); + StrategyNexthopState *state = + (StrategyNexthopState *) parcHashMap_Get(strategy->strategy_state, cid); + parcObject_Release((void **) &state); + } + parcIterator_Release(&it); - PARCIterator *it = parcHashMap_CreateKeyIterator(strategy->strategy_state); - while (parcIterator_HasNext(it)) { - PARCUnsigned *cid = parcIterator_Next(it); - StrategyNexthopState *state = - (StrategyNexthopState *)parcHashMap_Get(strategy->strategy_state, cid); - parcObject_Release((void**)&state); - } - parcIterator_Release(&it); - - parcHashMap_Release(&(strategy->strategy_state)); + parcHashMap_Release(&(strategy->strategy_state)); #ifndef WITH_POLICY - numberSet_Release(&(strategy->nexthops)); + numberSet_Release(&(strategy->nexthops)); #endif /* ! WITH_POLICY */ - parcMemory_Deallocate((void **)&strategy); - parcMemory_Deallocate((void **)&impl); - *strategyPtr = NULL; + parcMemory_Deallocate((void **) &strategy); + parcMemory_Deallocate((void **) &impl); + *strategyPtr = NULL; + } } |