BIND 10 master, updated. b1b6e109cda0458811ab61be4263a51b5520ce0b [master] Fix leaks in AllocEngine tests reported by Valgrind
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Nov 1 08:52:14 UTC 2012
The branch, master has been updated
via b1b6e109cda0458811ab61be4263a51b5520ce0b (commit)
from 9a15250b2c74f8b637cf1f32f79cc626cb05d0e5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b1b6e109cda0458811ab61be4263a51b5520ce0b
Author: Mukund Sivaraman <muks at isc.org>
Date: Thu Nov 1 13:56:17 2012 +0530
[master] Fix leaks in AllocEngine tests reported by Valgrind
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcp/tests/alloc_engine_unittest.cc | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/tests/alloc_engine_unittest.cc b/src/lib/dhcp/tests/alloc_engine_unittest.cc
index 8bbaf09..945c8e9 100644
--- a/src/lib/dhcp/tests/alloc_engine_unittest.cc
+++ b/src/lib/dhcp/tests/alloc_engine_unittest.cc
@@ -20,6 +20,7 @@
#include <dhcp/cfgmgr.h>
#include "memfile_lease_mgr.h"
#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
#include <iostream>
#include <sstream>
#include <map>
@@ -95,7 +96,6 @@ public:
// This test checks if the Allocation Engine can be instantiated and that it
// parses parameters string properly.
TEST_F(AllocEngineTest, constructor) {
-
AllocEngine* x = NULL;
// Hashed and random allocators are not supported yet
@@ -130,9 +130,8 @@ detailCompareLease6(const Lease6Ptr& first, const Lease6Ptr& second) {
// This test checks if the simple allocation can succeed
TEST_F(AllocEngineTest, simpleAlloc) {
-
- AllocEngine* engine = NULL;
- ASSERT_NO_THROW(engine = new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
+ boost::scoped_ptr<AllocEngine>(engine);
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
ASSERT_TRUE(engine);
Lease6Ptr lease = engine->allocateAddress6(subnet_, duid_, iaid_, IOAddress("::"),
@@ -154,9 +153,8 @@ TEST_F(AllocEngineTest, simpleAlloc) {
// This test checks if the fake allocation (for SOLICIT) can succeed
TEST_F(AllocEngineTest, fakeAlloc) {
-
- AllocEngine* engine = NULL;
- ASSERT_NO_THROW(engine = new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
+ boost::scoped_ptr<AllocEngine>(engine);
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
ASSERT_TRUE(engine);
Lease6Ptr lease = engine->allocateAddress6(subnet_, duid_, iaid_, IOAddress("::"),
@@ -176,9 +174,8 @@ TEST_F(AllocEngineTest, fakeAlloc) {
// This test checks if the allocation with a hint that is valid (in range,
// in pool and free) can succeed
TEST_F(AllocEngineTest, allocWithValidHint) {
-
- AllocEngine* engine = NULL;
- ASSERT_NO_THROW(engine = new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
+ boost::scoped_ptr<AllocEngine>(engine);
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
ASSERT_TRUE(engine);
Lease6Ptr lease = engine->allocateAddress6(subnet_, duid_, iaid_,
@@ -205,9 +202,8 @@ TEST_F(AllocEngineTest, allocWithValidHint) {
// This test checks if the allocation with a hint that is in range,
// in pool, but is currently used) can succeed
TEST_F(AllocEngineTest, allocWithUsedHint) {
-
- AllocEngine* engine = NULL;
- ASSERT_NO_THROW(engine = new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
+ boost::scoped_ptr<AllocEngine>(engine);
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
ASSERT_TRUE(engine);
// let's create a lease and put it in the LeaseMgr
@@ -245,9 +241,8 @@ TEST_F(AllocEngineTest, allocWithUsedHint) {
// This test checks if the allocation with a hint that is out the blue
// can succeed. The invalid hint should be ignored completely.
TEST_F(AllocEngineTest, allocBogusHint) {
-
- AllocEngine* engine = NULL;
- ASSERT_NO_THROW(engine = new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
+ boost::scoped_ptr<AllocEngine>(engine);
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
ASSERT_TRUE(engine);
// Client would like to get a 3000::abc lease, which does not belong to any
More information about the bind10-changes
mailing list