[svn] commit: r3995 - in /branches/trac446/src/bin/auth: config.cc config.h tests/config_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Dec 23 20:09:33 UTC 2010


Author: jinmei
Date: Thu Dec 23 20:09:32 2010
New Revision: 3995

Log:
addressed a review comment:
 - removed destroyAuthConfigParser()
 - adjusted the test code and documentation accordingly

Modified:
    branches/trac446/src/bin/auth/config.cc
    branches/trac446/src/bin/auth/config.h
    branches/trac446/src/bin/auth/tests/config_unittest.cc

Modified: branches/trac446/src/bin/auth/config.cc
==============================================================================
--- branches/trac446/src/bin/auth/config.cc (original)
+++ branches/trac446/src/bin/auth/config.cc Thu Dec 23 20:09:32 2010
@@ -164,7 +164,7 @@
 }
 
 // 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 @@
 }
 
 void
-destroyAuthConfigParser(AuthConfigParser* parser) {
-    delete parser;
-}
-
-void
 configureAuthServer(AuthSrv& server, ConstElementPtr config_set) {
     if (!config_set) {
         isc_throw(AuthConfigError,

Modified: branches/trac446/src/bin/auth/config.h
==============================================================================
--- branches/trac446/src/bin/auth/config.h (original)
+++ branches/trac446/src/bin/auth/config.h Thu Dec 23 20:09:32 2010
@@ -163,8 +163,13 @@
 /// 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 @@
 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:

Modified: branches/trac446/src/bin/auth/tests/config_unittest.cc
==============================================================================
--- branches/trac446/src/bin/auth/tests/config_unittest.cc (original)
+++ branches/trac446/src/bin/auth/tests/config_unittest.cc Thu Dec 23 20:09:32 2010
@@ -109,7 +109,7 @@
         parser(createAuthConfigParser(server, "datasources"))
     {}
     ~MemoryDatasrcConfigTest() {
-        destroyAuthConfigParser(parser);
+        delete parser;
     }
     AuthConfigParser* parser;
 };
@@ -170,7 +170,7 @@
 
     // 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 @@
     parser->commit();
     EXPECT_EQ(1, server.getMemoryDataSrc(rrclass)->getZoneCount());
 
-    destroyAuthConfigParser(parser);
+    delete parser;
     parser = createAuthConfigParser(server, "datasources"); 
     parser->build(Element::fromJSON("[]"));
     parser->commit();




More information about the bind10-changes mailing list