Skip to content

Commit d789968

Browse files
committed
replace malloc/free with new/delete
Signed-off-by: Rosen Penev <[email protected]>
1 parent b53ed72 commit d789968

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/basicio.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ void XPathIo::ReadDataUri(const std::string& path) {
889889
throw Error(ErrorCode::kerErrorMessage, "No base64 data");
890890

891891
std::string data = path.substr(base64Pos + 7);
892-
char* decodeData = new char[data.length()];
892+
auto decodeData = new char[data.length()];
893893
auto size = base64decode(data.c_str(), decodeData, data.length());
894894
if (size > 0)
895895
write((byte*)decodeData, size);

src/properties.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4899,10 +4899,10 @@ void XmpProperties::registerNs(const std::string& ns, const std::string& prefix)
48994899
// Using malloc/free for better system compatibility in case
49004900
// users don't unregister their namespaces explicitly.
49014901
XmpNsInfo xn;
4902-
auto c = static_cast<char*>(std::malloc(ns2.size() + 1));
4902+
auto c = new char[ns2.size() + 1];
49034903
std::strcpy(c, ns2.c_str());
49044904
xn.ns_ = c;
4905-
c = static_cast<char*>(std::malloc(prefix.size() + 1));
4905+
c = new char[prefix.size() + 1];
49064906
std::strcpy(c, prefix.c_str());
49074907
xn.prefix_ = c;
49084908
xn.xmpPropertyInfo_ = nullptr;
@@ -4918,8 +4918,8 @@ void XmpProperties::unregisterNs(const std::string& ns) {
49184918
void XmpProperties::unregisterNsUnsafe(const std::string& ns) {
49194919
auto i = nsRegistry_.find(ns);
49204920
if (i != nsRegistry_.end()) {
4921-
std::free(const_cast<char*>(i->second.prefix_));
4922-
std::free(const_cast<char*>(i->second.ns_));
4921+
delete[] i->second.prefix_;
4922+
delete[] i->second.ns_;
49234923
nsRegistry_.erase(i);
49244924
}
49254925
}

0 commit comments

Comments
 (0)