Browse Source

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

JINMEI Tatuya 14 years ago
parent
commit
a414307769
3 changed files with 11 additions and 26 deletions
  1. 1 6
      src/bin/auth/config.cc
  2. 7 17
      src/bin/auth/config.h
  3. 3 3
      src/bin/auth/tests/config_unittest.cc

+ 1 - 6
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,

+ 7 - 17
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:

+ 3 - 3
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();