1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 17:14:07 +01:00

Define make_unique properly, use in at least one commonly visited place...

Which is file opening.

So we can be sure it compiles and works on all platforms.
This commit is contained in:
Paul Licameli
2016-02-14 21:30:39 -05:00
parent 7f223c261a
commit 7988e814bd
2 changed files with 54 additions and 16 deletions

View File

@@ -217,15 +217,14 @@ bool XMLTagHandler::ReadXMLTag(const char *tag, const char **attrs)
// const char **out_attrs = NEW char (const char *)[tmp_attrs.GetCount()+1];
// however MSVC doesn't like the constness in this position, so this is now
// added by a cast after creating the array of pointers-to-non-const chars.
const wxChar **out_attrs = (const wxChar**)new wxChar *[tmp_attrs.GetCount()+1];
auto out_attrs = std::make_unique<const wxChar *[]>(tmp_attrs.GetCount() + 1);
for (size_t i=0; i<tmp_attrs.GetCount(); i++) {
out_attrs[i] = tmp_attrs[i].c_str();
}
out_attrs[tmp_attrs.GetCount()] = 0;
bool result = HandleXMLTag(UTF8CTOWX(tag).c_str(), out_attrs);
bool result = HandleXMLTag(UTF8CTOWX(tag).c_str(), out_attrs.get());
delete[] out_attrs;
return result;
}