C++: Use `free()` instead of `delete` for C things
diff --git a/src/Array.cpp b/src/Array.cpp
index bc448d3..be7eb86 100644
--- a/src/Array.cpp
+++ b/src/Array.cpp
@@ -168,7 +168,7 @@
std::vector<Node*>::iterator it = _array.begin();
it += pos;
_array.erase(it);
- delete node;
+ free(node);
}
}
diff --git a/src/Data.cpp b/src/Data.cpp
index a96fc50..b06a144 100644
--- a/src/Data.cpp
+++ b/src/Data.cpp
@@ -66,14 +66,10 @@
std::vector<char> Data::GetValue() const
{
- char* buff = NULL;
uint64_t length = 0;
- plist_get_data_val(_node, &buff, &length);
+ const char* buff = plist_get_data_ptr(_node, &length);
std::vector<char> ret(buff, buff + length);
- delete buff;
return ret;
}
-
-
} // namespace PList
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp
index 30c20b6..f5fd239 100644
--- a/src/Dictionary.cpp
+++ b/src/Dictionary.cpp
@@ -40,7 +40,7 @@
plist_dict_next_item(node, it, &key, &subnode);
if (key && subnode)
map[std::string(key)] = Node::FromPlist(subnode, _this);
- delete key;
+ free(key);
} while (subnode);
free(it);
}
@@ -176,9 +176,9 @@
plist_dict_get_item_key(node->GetPlist(), &key);
plist_dict_remove_item(_node, key);
std::string skey = key;
- delete key;
+ free(key);
_map.erase(skey);
- delete node;
+ free(node);
}
}
diff --git a/src/Key.cpp b/src/Key.cpp
index 79265d5..86a0bf8 100644
--- a/src/Key.cpp
+++ b/src/Key.cpp
@@ -69,7 +69,7 @@
char* s = NULL;
plist_get_key_val(_node, &s);
std::string ret = s ? s : "";
- delete s;
+ free(s);
return ret;
}
diff --git a/src/Structure.cpp b/src/Structure.cpp
index b33de96..f56b0e6 100644
--- a/src/Structure.cpp
+++ b/src/Structure.cpp
@@ -57,7 +57,7 @@
uint32_t length = 0;
plist_to_xml(_node, &xml, &length);
std::string ret(xml, xml+length);
- delete xml;
+ free(xml);
return ret;
}
@@ -67,7 +67,7 @@
uint32_t length = 0;
plist_to_bin(_node, &bin, &length);
std::vector<char> ret(bin, bin+length);
- delete bin;
+ free(bin);
return ret;
}