@@ -24,10 +24,10 @@ Backup::Backup(Database& aDestDatabase,
2424 Database& aSrcDatabase,
2525 const char * apSrcDatabaseName)
2626{
27- mpSQLiteBackup. reset ( sqlite3_backup_init (aDestDatabase.getHandle (),
27+ mpSQLiteBackup = sqlite3_backup_init (aDestDatabase.getHandle (),
2828 apDestDatabaseName,
2929 aSrcDatabase.getHandle (),
30- apSrcDatabaseName)) ;
30+ apSrcDatabaseName);
3131 if (nullptr == mpSQLiteBackup)
3232 {
3333 // If an error occurs, the error code and message are attached to the destination database connection.
@@ -48,10 +48,19 @@ Backup::Backup(Database &aDestDatabase, Database &aSrcDatabase) :
4848{
4949}
5050
51+ // Release resource for SQLite database backup
52+ Backup::~Backup ()
53+ {
54+ if (mpSQLiteBackup)
55+ {
56+ sqlite3_backup_finish (mpSQLiteBackup);
57+ }
58+ }
59+
5160// Execute backup step with a given number of source pages to be copied
5261int Backup::executeStep (const int aNumPage /* = -1 */ )
5362{
54- const int res = sqlite3_backup_step (mpSQLiteBackup. get () , aNumPage);
63+ const int res = sqlite3_backup_step (mpSQLiteBackup, aNumPage);
5564 if (SQLITE_OK != res && SQLITE_DONE != res && SQLITE_BUSY != res && SQLITE_LOCKED != res)
5665 {
5766 throw SQLite::Exception (sqlite3_errstr (res), res);
@@ -62,22 +71,14 @@ int Backup::executeStep(const int aNumPage /* = -1 */)
6271// Get the number of remaining source pages to be copied in this backup process
6372int Backup::getRemainingPageCount () const
6473{
65- return sqlite3_backup_remaining (mpSQLiteBackup. get () );
74+ return sqlite3_backup_remaining (mpSQLiteBackup);
6675}
6776
6877// Get the number of total source pages to be copied in this backup process
6978int Backup::getTotalPageCount () const
7079{
71- return sqlite3_backup_pagecount (mpSQLiteBackup. get () );
80+ return sqlite3_backup_pagecount (mpSQLiteBackup);
7281}
7382
74- // Release resource for SQLite database backup
75- void SQLite::Backup::Deleter::operator ()(sqlite3_backup* apBackup)
76- {
77- if (apBackup)
78- {
79- sqlite3_backup_finish (apBackup);
80- }
81- }
8283
8384} // namespace SQLite
0 commit comments