delete m_pdbf in destruction?
-
hi, all when this app open the customer dbf file, it creats index as well, it didn't really has m_pdbf = new...., but it seems like need to be deleted in dbCustomer::~dbCustomer(), here is the steps: BOOL dbCustomer::Open( const char *pszFileName, bool bReindex ) { ASSERT( m_pdbf == NULL ); int nError = 0; std::string strErrMsg = ""; if ( !OpenDbfNtx( &m_pdbf, pszFileName, NULL, NULL, nError, &strErrMsg ) ) throw DbfAccessException (string(pszFileName) + " not found", RC_DBF_UNABLE_TO_OPEN); SetIndex( pszFileName, m_pdbf, bReindex ); m_pdbf->set_order( "CUSNUM02" ); return BindFieldOrdinals(); } CB_DBF_NTX* const p = OpenDbfNtxHelper( szDbfName, szIndexName, szIndexKey ); CB_DBF_NTX* pDbf = new CB_DBF_NTX( const_cast( szDbfName ) ); the wrapper seems conplicated, it's getting infor from library files.........thanks for your time
-
hi, all when this app open the customer dbf file, it creats index as well, it didn't really has m_pdbf = new...., but it seems like need to be deleted in dbCustomer::~dbCustomer(), here is the steps: BOOL dbCustomer::Open( const char *pszFileName, bool bReindex ) { ASSERT( m_pdbf == NULL ); int nError = 0; std::string strErrMsg = ""; if ( !OpenDbfNtx( &m_pdbf, pszFileName, NULL, NULL, nError, &strErrMsg ) ) throw DbfAccessException (string(pszFileName) + " not found", RC_DBF_UNABLE_TO_OPEN); SetIndex( pszFileName, m_pdbf, bReindex ); m_pdbf->set_order( "CUSNUM02" ); return BindFieldOrdinals(); } CB_DBF_NTX* const p = OpenDbfNtxHelper( szDbfName, szIndexName, szIndexKey ); CB_DBF_NTX* pDbf = new CB_DBF_NTX( const_cast( szDbfName ) ); the wrapper seems conplicated, it's getting infor from library files.........thanks for your time
depends on your design. if there's an
Open
method, maybe there's aClose
method also that will close the database and delete the object. if you're not certain about that, put the delete in the destructor.
Maximilien Lincourt Your Head A Splode - Strong Bad