From 9391847534f3c728072ad9da1766139649fa5957 Mon Sep 17 00:00:00 2001 From: YZBruh Date: Fri, 15 Aug 2025 20:02:29 +0300 Subject: [PATCH] Reapply "pmt: use constructor/destructor attributes insetad of class" This reverts commit d4703df1a5f5ee4c2fe3fb51670b25553a92c0eb. --- include/PartitionManager/PartitionManager.hpp | 11 ----------- src/PartitionManager.cpp | 15 ++++++++------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/include/PartitionManager/PartitionManager.hpp b/include/PartitionManager/PartitionManager.hpp index 87459b3..c5d9f52 100644 --- a/include/PartitionManager/PartitionManager.hpp +++ b/include/PartitionManager/PartitionManager.hpp @@ -70,17 +70,6 @@ public: bool forceProcess; }; -class variableProtect final { -private: - basic_variables *_ptr = nullptr; - -public: - variableProtect(); - ~variableProtect(); - - void setVariablePointer(basic_variables *&_ptr); -}; - using FunctionBase = basic_function; using FunctionManager = basic_function_manager; using VariableTable = basic_variables; diff --git a/src/PartitionManager.cpp b/src/PartitionManager.cpp index 40292bd..0a71904 100644 --- a/src/PartitionManager.cpp +++ b/src/PartitionManager.cpp @@ -24,17 +24,19 @@ #include namespace PartitionManager { -variableProtect protector; -auto Variables = new VariableTable(); -variableProtect::variableProtect() { +__attribute__((constructor)) +void init() { Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log"); } -variableProtect::~variableProtect() { delete _ptr; } -void variableProtect::setVariablePointer(basic_variables *&_ptr) { - this->_ptr = _ptr; + +__attribute__((destructor)) +void cleanup() { + delete Variables; } +auto Variables = new VariableTable(); + basic_variables::~basic_variables() { delete PartMap; } basic_variables::basic_variables() : logFile(Helper::LoggingProperties::FILE), onLogical(false), @@ -50,7 +52,6 @@ int Main(int argc, char **argv) { try { // try-catch start CLI::App AppMain{"Partition Manager Tool"}; - protector.setVariablePointer(Variables); FunctionManager FuncManager; AppMain.fallthrough(true);