Changeset 2228

Show
Ignore:
Timestamp:
08/08/2008 22:50:28 (2 years ago)
Author:
chris
Message:

Replace manual pointer management with std::auto_ptr.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/common/Configuration.cpp

    r2155 r2228  
    200200         
    201201        // Object to create 
    202         Configuration *pconfig = new Configuration(std::string("<root>")); 
     202        std::auto_ptr<Configuration> apConfig( 
     203                new Configuration(std::string("<root>"))); 
    203204         
    204205        try 
    205206        { 
    206207                // Load 
    207                 LoadInto(*pconfig, getline, rErrorMsg, true); 
     208                LoadInto(*apConfig, getline, rErrorMsg, true); 
    208209 
    209210                if(!rErrorMsg.empty()) 
     
    212213                        BOX_ERROR("Error in Configuration::LoadInto: " <<  
    213214                                rErrorMsg); 
    214                         delete pconfig; 
    215                         pconfig = 0; 
    216215                        return std::auto_ptr<Configuration>(0); 
    217216                } 
     
    220219                if(pVerify) 
    221220                { 
    222                         if(!Verify(*pconfig, *pVerify, std::string(), rErrorMsg)) 
     221                        if(!Verify(*apConfig, *pVerify, std::string(), 
     222                                rErrorMsg)) 
    223223                        { 
    224224                                BOX_ERROR("Error verifying configuration: " << 
    225225                                        rErrorMsg); 
    226                                 delete pconfig; 
    227                                 pconfig = 0; 
    228226                                return std::auto_ptr<Configuration>(0); 
    229227                        } 
     
    233231        { 
    234232                // Clean up 
    235                 delete pconfig; 
    236                 pconfig = 0; 
    237233                throw; 
    238234        } 
    239235         
    240236        // Success. Return result. 
    241         return std::auto_ptr<Configuration>(pconfig); 
     237        return apConfig; 
    242238} 
    243239