Browse Source

[2387] Add comments on use of auto_ptr

Mukund Sivaraman 12 years ago
parent
commit
82fc64bf97

+ 3 - 0
src/lib/dns/rdata/generic/dnskey_48.cc

@@ -72,6 +72,9 @@ struct DNSKEYImpl {
 DNSKEY::DNSKEY(const std::string& dnskey_str) :
     impl_(NULL)
 {
+    // We use auto_ptr here because if there is an exception in this
+    // constructor, the destructor is not called and there could be a
+    // leak of the DNSKEYImpl that constructFromLexer() returns.
     std::auto_ptr<DNSKEYImpl> impl_ptr(NULL);
 
     try {

+ 3 - 0
src/lib/dns/rdata/generic/nsec3_50.cc

@@ -87,6 +87,9 @@ struct NSEC3Impl {
 NSEC3::NSEC3(const std::string& nsec3_str) :
     impl_(NULL)
 {
+    // We use auto_ptr here because if there is an exception in this
+    // constructor, the destructor is not called and there could be a
+    // leak of the NSEC3Impl that constructFromLexer() returns.
     std::auto_ptr<NSEC3Impl> impl_ptr(NULL);
 
     try {

+ 3 - 0
src/lib/dns/rdata/generic/nsec3param_51.cc

@@ -65,6 +65,9 @@ struct NSEC3PARAMImpl {
 NSEC3PARAM::NSEC3PARAM(const std::string& nsec3param_str) :
     impl_(NULL)
 {
+    // We use auto_ptr here because if there is an exception in this
+    // constructor, the destructor is not called and there could be a
+    // leak of the NSEC3PARAMImpl that constructFromLexer() returns.
     std::auto_ptr<NSEC3PARAMImpl> impl_ptr(NULL);
 
     try {