diff options
author | Mauro Sardara <msardara@cisco.com> | 2022-09-15 11:06:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2022-09-15 11:06:52 +0000 |
commit | df9f9d7967df41bf90628c2072419a21669fb9ce (patch) | |
tree | 9b7e2342bba3dd36240203c42697a79538c8228b | |
parent | f7567c8987065582d4ffde710ec54b7abdb619a2 (diff) | |
parent | 2c5b861c8055ef68038273110ea81975e1c6b425 (diff) |
Merge "fix(strategy): fix memory leaks detected by valgrind in unit tests"
-rw-r--r-- | hicn-light/src/hicn/core/strategy.c | 4 | ||||
-rw-r--r-- | hicn-light/src/hicn/core/strategy.h | 2 | ||||
-rw-r--r-- | hicn-light/src/hicn/test/test-strategy-best-path.cc | 2 | ||||
-rw-r--r-- | hicn-light/src/hicn/test/test-strategy-replication.cc | 2 | ||||
-rw-r--r-- | lib/src/test/test_name.cc | 2 |
5 files changed, 10 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_; diff --git a/lib/src/test/test_name.cc b/lib/src/test/test_name.cc index 35e636b63..dbeab96cc 100644 --- a/lib/src/test/test_name.cc +++ b/lib/src/test/test_name.cc @@ -31,9 +31,11 @@ protected: NameTest () : name_{}, name4_{}, name6_{} { + ipv6_prefix_bytes = {}; int rc = inet_pton (AF_INET6, ipv6_prefix, &ipv6_prefix_bytes.v6); EXPECT_EQ (rc, 1); + ipv4_prefix_bytes = {}; rc = inet_pton (AF_INET, ipv4_prefix, &ipv4_prefix_bytes.v4); EXPECT_EQ (rc, 1); |