summaryrefslogtreecommitdiffstats
path: root/hicn-light/src
diff options
context:
space:
mode:
authorEnrico Loparco (eloparco) <eloparco@cisco.com>2022-09-14 15:57:25 +0000
committerEnrico Loparco (eloparco) <eloparco@cisco.com>2022-09-14 15:57:25 +0000
commit2c5b861c8055ef68038273110ea81975e1c6b425 (patch)
tree204481342c99c31c0e4a47df92dd840bc9cc15fa /hicn-light/src
parentab38321508d886f0acd535f0f5f07a3d44e29591 (diff)
fix(strategy): fix memory leaks detected by valgrind in unit tests
Ref: HICN-785 Signed-off-by: Enrico Loparco (eloparco) <eloparco@cisco.com> Change-Id: I0102bdba4257b891fc6843d42e6eccc5e48687dc
Diffstat (limited to 'hicn-light/src')
-rw-r--r--hicn-light/src/hicn/core/strategy.c4
-rw-r--r--hicn-light/src/hicn/core/strategy.h2
-rw-r--r--hicn-light/src/hicn/test/test-strategy-best-path.cc2
-rw-r--r--hicn-light/src/hicn/test/test-strategy-replication.cc2
4 files changed, 8 insertions, 2 deletions
diff --git a/hicn-light/src/hicn/core/strategy.c b/hicn-light/src/hicn/core/strategy.c
index 3716cd585..46c83ef02 100644
--- a/hicn-light/src/hicn/core/strategy.c
+++ b/hicn-light/src/hicn/core/strategy.c
@@ -26,6 +26,10 @@ int strategy_initialize(strategy_entry_t *entry, const void *forwarder) {
return strategy_vft[entry->type]->initialize(entry, forwarder);
}
+int strategy_finalize(strategy_entry_t *entry) {
+ return strategy_vft[entry->type]->finalize(entry);
+}
+
nexthops_t *strategy_lookup_nexthops(strategy_entry_t *entry,
nexthops_t *nexthops,
const msgbuf_t *msgbuf) {
diff --git a/hicn-light/src/hicn/core/strategy.h b/hicn-light/src/hicn/core/strategy.h
index 9ce75c51d..9f1a7dac7 100644
--- a/hicn-light/src/hicn/core/strategy.h
+++ b/hicn-light/src/hicn/core/strategy.h
@@ -59,6 +59,8 @@ typedef struct strategy_entry_s {
int strategy_initialize(strategy_entry_t *entry, const void *forwarder);
+int strategy_finalize(strategy_entry_t *entry);
+
nexthops_t *strategy_lookup_nexthops(strategy_entry_t *entry,
nexthops_t *nexthops,
const msgbuf_t *msgbuf);
diff --git a/hicn-light/src/hicn/test/test-strategy-best-path.cc b/hicn-light/src/hicn/test/test-strategy-best-path.cc
index 327c47144..f909c15f2 100644
--- a/hicn-light/src/hicn/test/test-strategy-best-path.cc
+++ b/hicn-light/src/hicn/test/test-strategy-best-path.cc
@@ -66,7 +66,7 @@ class StrategyBestpathTest : public ::testing::Test {
ticks_ = ticks_now();
}
- virtual ~StrategyBestpathTest() {}
+ virtual ~StrategyBestpathTest() { strategy_finalize(&entry); }
strategy_entry_t entry;
nexthops_t available_nexthops_;
diff --git a/hicn-light/src/hicn/test/test-strategy-replication.cc b/hicn-light/src/hicn/test/test-strategy-replication.cc
index 2924173cb..1c4d824b8 100644
--- a/hicn-light/src/hicn/test/test-strategy-replication.cc
+++ b/hicn-light/src/hicn/test/test-strategy-replication.cc
@@ -61,7 +61,7 @@ class StrategyReplicationTest : public ::testing::Test {
ticks_ = ticks_now();
}
- virtual ~StrategyReplicationTest() {}
+ virtual ~StrategyReplicationTest() { strategy_finalize(&entry); }
strategy_entry_t entry;
nexthops_t available_nexthops_;