pmt: use smart pointers for more safe memory
This commit is contained in:
@@ -58,9 +58,8 @@ public:
|
|||||||
class basic_variables final {
|
class basic_variables final {
|
||||||
public:
|
public:
|
||||||
basic_variables();
|
basic_variables();
|
||||||
~basic_variables();
|
|
||||||
|
|
||||||
PartitionMap::BuildMap *PartMap;
|
std::unique_ptr<PartitionMap::BuildMap> PartMap;
|
||||||
|
|
||||||
std::string searchPath, logFile;
|
std::string searchPath, logFile;
|
||||||
bool onLogical;
|
bool onLogical;
|
||||||
@@ -75,7 +74,7 @@ using FunctionManager = basic_function_manager;
|
|||||||
using VariableTable = basic_variables;
|
using VariableTable = basic_variables;
|
||||||
using Error = Helper::Error;
|
using Error = Helper::Error;
|
||||||
|
|
||||||
extern VariableTable *Variables;
|
extern std::unique_ptr<VariableTable> Variables;
|
||||||
|
|
||||||
int Main(int argc, char **argv);
|
int Main(int argc, char **argv);
|
||||||
|
|
||||||
|
|||||||
@@ -30,20 +30,14 @@ void init() {
|
|||||||
Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log");
|
Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log");
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((destructor))
|
auto Variables = std::make_unique<VariableTable>();
|
||||||
void cleanup() {
|
|
||||||
delete Variables;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto Variables = new VariableTable();
|
|
||||||
|
|
||||||
basic_variables::~basic_variables() { delete PartMap; }
|
|
||||||
basic_variables::basic_variables()
|
basic_variables::basic_variables()
|
||||||
: logFile("/sdcard/Documents/last_pmt_logs.log"), onLogical(false),
|
: logFile("/sdcard/Documents/last_pmt_logs.log"), onLogical(false),
|
||||||
quietProcess(false), verboseMode(false), viewVersion(false),
|
quietProcess(false), verboseMode(false), viewVersion(false),
|
||||||
forceProcess(false) {
|
forceProcess(false) {
|
||||||
try {
|
try {
|
||||||
PartMap = new PartitionMap::BuildMap();
|
PartMap = std::make_unique<PartitionMap::BuildMap>();
|
||||||
} catch (std::exception &) {
|
} catch (std::exception &) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user