replace malloc/free with new/delete

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago
parent b53ed72fd8
commit d789968e90

@ -889,7 +889,7 @@ void XPathIo::ReadDataUri(const std::string& path) {
throw Error(ErrorCode::kerErrorMessage, "No base64 data");
std::string data = path.substr(base64Pos + 7);
char* decodeData = new char[data.length()];
auto decodeData = new char[data.length()];
auto size = base64decode(data.c_str(), decodeData, data.length());
if (size > 0)
write((byte*)decodeData, size);

@ -4899,10 +4899,10 @@ void XmpProperties::registerNs(const std::string& ns, const std::string& prefix)
// Using malloc/free for better system compatibility in case
// users don't unregister their namespaces explicitly.
XmpNsInfo xn;
auto c = static_cast<char*>(std::malloc(ns2.size() + 1));
auto c = new char[ns2.size() + 1];
std::strcpy(c, ns2.c_str());
xn.ns_ = c;
c = static_cast<char*>(std::malloc(prefix.size() + 1));
c = new char[prefix.size() + 1];
std::strcpy(c, prefix.c_str());
xn.prefix_ = c;
xn.xmpPropertyInfo_ = nullptr;
@ -4918,8 +4918,8 @@ void XmpProperties::unregisterNs(const std::string& ns) {
void XmpProperties::unregisterNsUnsafe(const std::string& ns) {
auto i = nsRegistry_.find(ns);
if (i != nsRegistry_.end()) {
std::free(const_cast<char*>(i->second.prefix_));
std::free(const_cast<char*>(i->second.ns_));
delete[] i->second.prefix_;
delete[] i->second.ns_;
nsRegistry_.erase(i);
}
}

Loading…
Cancel
Save