mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-23 04:20:56 +00:00
Avoid leaks running "gen" when memory sanitizer is enabled
This commit is contained in:
parent
6dccb1986e
commit
cdf271af74
@ -1,4 +1,4 @@
|
||||
Copyright (C) 2019 Igara Studio S.A.
|
||||
Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
Copyright (C) 2014-2018 David Capello
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Code Generator
|
||||
// Copyright (c) 2021 Igara Studio S.A.
|
||||
// Copyright (c) 2016-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -90,9 +91,9 @@ public:
|
||||
|
||||
void loadStrings(const std::string& dir) {
|
||||
for (const auto& fn : base::list_files(dir)) {
|
||||
cfg::CfgFile* f = new cfg::CfgFile;
|
||||
std::unique_ptr<cfg::CfgFile> f(new cfg::CfgFile);
|
||||
f->load(base::join_path(dir, fn));
|
||||
m_stringFiles.push_back(f);
|
||||
m_stringFiles.push_back(std::move(f));
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +184,7 @@ public:
|
||||
if (!text)
|
||||
return; // Do nothing
|
||||
else if (text[0] == '@') {
|
||||
for (auto cfg : m_stringFiles) {
|
||||
for (auto& cfg : m_stringFiles) {
|
||||
std::string lang = base::get_file_title(cfg->filename());
|
||||
std::string section, var;
|
||||
|
||||
@ -222,7 +223,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<cfg::CfgFile*> m_stringFiles;
|
||||
std::vector<std::unique_ptr<cfg::CfgFile>> m_stringFiles;
|
||||
std::string m_prefixId;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Code Generator
|
||||
// Copyright (c) 2021 Igara Studio S.A.
|
||||
// Copyright (c) 2014-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -17,6 +18,7 @@
|
||||
#include "tinyxml.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
typedef base::ProgramOptions PO;
|
||||
|
||||
@ -36,13 +38,13 @@ static void run(int argc, const char* argv[])
|
||||
po.parse(argc, argv);
|
||||
|
||||
// Try to load the XML file
|
||||
TiXmlDocument* doc = nullptr;
|
||||
std::unique_ptr<TiXmlDocument> doc;
|
||||
|
||||
std::string inputFilename = po.value_of(inputOpt);
|
||||
if (!inputFilename.empty() &&
|
||||
base::get_file_extension(inputFilename) == "xml") {
|
||||
base::FileHandle inputFile(base::open_file(inputFilename, "rb"));
|
||||
doc = new TiXmlDocument();
|
||||
doc.reset(new TiXmlDocument);
|
||||
doc->SetValue(inputFilename.c_str());
|
||||
if (!doc->LoadFile(inputFile.get())) {
|
||||
std::cerr << doc->Value() << ":"
|
||||
@ -58,16 +60,16 @@ static void run(int argc, const char* argv[])
|
||||
if (doc) {
|
||||
// Generate widget class
|
||||
if (po.enabled(widgetId))
|
||||
gen_ui_class(doc, inputFilename, po.value_of(widgetId));
|
||||
gen_ui_class(doc.get(), inputFilename, po.value_of(widgetId));
|
||||
// Generate preference header file
|
||||
else if (po.enabled(prefH))
|
||||
gen_pref_header(doc, inputFilename);
|
||||
gen_pref_header(doc.get(), inputFilename);
|
||||
// Generate preference c++ file
|
||||
else if (po.enabled(prefCpp))
|
||||
gen_pref_impl(doc, inputFilename);
|
||||
gen_pref_impl(doc.get(), inputFilename);
|
||||
// Generate theme class
|
||||
else if (po.enabled(theme))
|
||||
gen_theme_class(doc, inputFilename);
|
||||
gen_theme_class(doc.get(), inputFilename);
|
||||
}
|
||||
// Generate strings.ini.h file
|
||||
else if (po.enabled(strings)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user