From 3e855cbdac6067a4f8fabc21836ef5453c2c4e84 Mon Sep 17 00:00:00 2001 From: Kamil Date: Fri, 4 Dec 2020 01:22:53 +0100 Subject: [PATCH] Close DB properly --- src/Database.cpp | 4 ++++ src/Database.hpp | 1 + src/main.cpp | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Database.cpp b/src/Database.cpp index 5367d39..38d395f 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -49,6 +49,10 @@ void Database::open() { std::cout << message << std::endl; } +void Database::close() { + sqlite3_close(db); +} + void Database::createTables() { char* errMsg = 0; diff --git a/src/Database.hpp b/src/Database.hpp index 3baec86..0f338a8 100644 --- a/src/Database.hpp +++ b/src/Database.hpp @@ -45,6 +45,7 @@ namespace Database { #pragma endregion DatabaseStructs void open(); + void close(); void createTables(); int getTableSize(std::string tableName); diff --git a/src/main.cpp b/src/main.cpp index aabfee3..d0b7f11 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,7 +48,8 @@ void terminate(int arg) { if (shardServer != nullptr && shardThread != nullptr) shardServer->kill(); - + + Database::close(); exit(0); }