mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Add a Statement::Ptr move constructor to fix leak because of ref counter incremented on copy
This commit is contained in:
parent
13c5d4f00c
commit
f2b1017710
@ -654,6 +654,12 @@ private:
|
||||
Ptr(sqlite3* apSQLite, std::string& aQuery);
|
||||
// Copy constructor increments the ref counter
|
||||
Ptr(const Ptr& aPtr);
|
||||
|
||||
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
|
||||
// Move constructor
|
||||
Ptr(Ptr&& aPtr);
|
||||
#endif
|
||||
|
||||
// Decrement the ref counter and finalize the sqlite3_stmt when it reaches 0
|
||||
~Ptr();
|
||||
|
||||
|
@ -456,6 +456,18 @@ Statement::Ptr::Ptr(const Statement::Ptr& aPtr) :
|
||||
++(*mpRefCount);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
|
||||
Statement::Ptr::Ptr(Ptr&& aPtr) :
|
||||
mpSQLite(aPtr.mpSQLite),
|
||||
mpStmt(aPtr.mpStmt),
|
||||
mpRefCount(aPtr.mpRefCount)
|
||||
{
|
||||
aPtr.mpSQLite = NULL;
|
||||
aPtr.mpStmt = NULL;
|
||||
aPtr.mpRefCount = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Decrement the ref counter and finalize the sqlite3_stmt when it reaches 0
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user