diff options
author | 2025-03-01 23:56:06 +0100 | |
---|---|---|
committer | 2025-03-01 23:56:06 +0100 | |
commit | 5ea6de69afcf11f2d2e59258cb055a5b1fdb5f82 (patch) | |
tree | adf925cb6b61b5279c2ad3627b2fd7bc48b34300 | |
parent | d40f03e4090edafea75f04a1697ef0384231d333 (diff) | |
download | libplist-5ea6de69afcf11f2d2e59258cb055a5b1fdb5f82.tar.gz libplist-5ea6de69afcf11f2d2e59258cb055a5b1fdb5f82.tar.bz2 |
C++: Use `free()` instead of `delete` for C things
-rw-r--r-- | src/Array.cpp | 2 | ||||
-rw-r--r-- | src/Data.cpp | 6 | ||||
-rw-r--r-- | src/Dictionary.cpp | 6 | ||||
-rw-r--r-- | src/Key.cpp | 2 | ||||
-rw-r--r-- | src/Structure.cpp | 4 |
5 files changed, 8 insertions, 12 deletions
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 @@ void Array::Remove(Node* node) 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 @@ void Data::SetValue(const std::vector<char>& buff) 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 @@ static void dictionary_fill(Dictionary *_this, std::map<std::string,Node*> &map, 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 @@ void Dictionary::Remove(Node* node) 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 @@ std::string Key::GetValue() const 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 @@ std::string Structure::ToXml() const 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 @@ std::vector<char> Structure::ToBin() const uint32_t length = 0; plist_to_bin(_node, &bin, &length); std::vector<char> ret(bin, bin+length); - delete bin; + free(bin); return ret; } |