diff options
author | JINMEI Tatuya <jinmei@isc.org> | 2010-12-23 21:09:32 +0100 |
---|---|---|
committer | JINMEI Tatuya <jinmei@isc.org> | 2010-12-23 21:09:32 +0100 |
commit | a414307769e43a70d7aacc69ed2d21cc4344eccf (patch) | |
tree | 8a014a888128647c3890bedc72afc5a53ce0c0c4 /src | |
parent | small updates: (diff) | |
download | kea-a414307769e43a70d7aacc69ed2d21cc4344eccf.tar.xz kea-a414307769e43a70d7aacc69ed2d21cc4344eccf.zip |
addressed a review comment:
- removed destroyAuthConfigParser()
- adjusted the test code and documentation accordingly
git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac446@3995 e5f2f494-b856-4b98-b285-d166d9295462
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/auth/config.cc | 7 | ||||
-rw-r--r-- | src/bin/auth/config.h | 24 | ||||
-rw-r--r-- | src/bin/auth/tests/config_unittest.cc | 6 |
3 files changed, 11 insertions, 26 deletions
diff --git a/src/bin/auth/config.cc b/src/bin/auth/config.cc index e898ccd4d1..f77acfc450 100644 --- a/src/bin/auth/config.cc +++ b/src/bin/auth/config.cc @@ -164,7 +164,7 @@ MemoryDatasourceConfig::build(ConstElementPtr config_value) { } // This is a generalized version of create function that can create -// a AuthConfigParser object for "internal" use. +// an AuthConfigParser object for "internal" use. AuthConfigParser* createAuthConfigParser(AuthSrv& server, const std::string& config_id, bool internal) @@ -190,11 +190,6 @@ createAuthConfigParser(AuthSrv& server, const std::string& config_id) { } void -destroyAuthConfigParser(AuthConfigParser* parser) { - delete parser; -} - -void configureAuthServer(AuthSrv& server, ConstElementPtr config_set) { if (!config_set) { isc_throw(AuthConfigError, diff --git a/src/bin/auth/config.h b/src/bin/auth/config.h index d71a16cbee..9931e627fc 100644 --- a/src/bin/auth/config.h +++ b/src/bin/auth/config.h @@ -163,8 +163,13 @@ void configureAuthServer(AuthSrv& server, /// In practice, this function is only expected to be used as a backend of /// \c configureAuthServer() and is not supposed to be called directly /// by applications. It is publicly available mainly for testing purposes. -/// When called directly, the created object must be destroyed using the -/// \c destroyAuthConfigParser() function. +/// When called directly, the created object must be deleted by the caller. +/// Note: this means if this module and the caller use incompatible sets of +/// new/delete, it may cause unexpected strange failure. We could avoid that +/// by providing a separate deallocation function or by using a smart pointer, +/// but since the expected usage of this function is very limited (i.e. for +/// our own testing purposes) it would be an overkilling. We therefore prefer +/// simplicity and keeping the interface intuitive. /// /// If the resource allocation for the new object fails, a corresponding /// standard exception will be thrown. Otherwise this function is not @@ -178,21 +183,6 @@ void configureAuthServer(AuthSrv& server, AuthConfigParser* createAuthConfigParser(AuthSrv& server, const std::string& config_id); -/// Destroy an \c AuthConfigParser object. -/// -/// This function destructs the \c parser and frees resources allocated for -/// it. \c parser must have been created by \c createAuthConfigParser(). -/// Like the create function, this function is mainly intended to be used -/// for testing purposes; normal applications are not expected to call it -/// directly. -/// -/// This function is not expected to throw an exception unless the underlying -/// implementation of \c parser (an object of a specific derived class of -/// \c AuthConfigParser) throws. -/// -/// \param parser A pointer to an \c AuthConfigParser object to be destroyed. -void destroyAuthConfigParser(AuthConfigParser* parser); - #endif // __CONFIG_H // Local Variables: diff --git a/src/bin/auth/tests/config_unittest.cc b/src/bin/auth/tests/config_unittest.cc index b1edbe0e54..8cc3bde523 100644 --- a/src/bin/auth/tests/config_unittest.cc +++ b/src/bin/auth/tests/config_unittest.cc @@ -109,7 +109,7 @@ protected: parser(createAuthConfigParser(server, "datasources")) {} ~MemoryDatasrcConfigTest() { - destroyAuthConfigParser(parser); + delete parser; } AuthConfigParser* parser; }; @@ -170,7 +170,7 @@ TEST_F(MemoryDatasrcConfigTest, replace) { // create a new parser, and install a new set of configuration. It // should replace the old one. - destroyAuthConfigParser(parser); + delete parser; parser = createAuthConfigParser(server, "datasources"); parser->build(Element::fromJSON( "[{\"type\": \"memory\"," @@ -193,7 +193,7 @@ TEST_F(MemoryDatasrcConfigTest, remove) { parser->commit(); EXPECT_EQ(1, server.getMemoryDataSrc(rrclass)->getZoneCount()); - destroyAuthConfigParser(parser); + delete parser; parser = createAuthConfigParser(server, "datasources"); parser->build(Element::fromJSON("[]")); parser->commit(); |