Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/c_api/connection.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <atomic>
#include <mutex>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -101,11 +102,12 @@ void lbug_connection_destroy(lbug_connection* connection) {
if (connection == nullptr) {
return;
}
if (connection->_connection != nullptr) {
auto connectionPtr = static_cast<Connection*>(connection->_connection);
std::atomic_ref<void*> atomic_conn(connection->_connection);
void* ptr = atomic_conn.exchange(nullptr);
if (ptr != nullptr) {
auto connectionPtr = static_cast<Connection*>(ptr);
forgetArrowTableIDs(connectionPtr);
delete connectionPtr;
connection->_connection = nullptr;
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/c_api/database.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <atomic>

#include "c_api/helpers.h"
#include "c_api/lbug.h"
#include "common/exception/exception.h"
Expand Down Expand Up @@ -31,9 +33,10 @@ void lbug_database_destroy(lbug_database* database) {
if (database == nullptr) {
return;
}
if (database->_database != nullptr) {
delete static_cast<Database*>(database->_database);
database->_database = nullptr;
std::atomic_ref<void*> atomic_db(database->_database);
void* ptr = atomic_db.exchange(nullptr);
if (ptr != nullptr) {
delete static_cast<Database*>(ptr);
}
}

Expand Down
Loading