summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2025-03-01 23:56:06 +0100
committerGravatar Nikias Bassen2025-03-01 23:56:06 +0100
commit5ea6de69afcf11f2d2e59258cb055a5b1fdb5f82 (patch)
treeadf925cb6b61b5279c2ad3627b2fd7bc48b34300 /src
parentd40f03e4090edafea75f04a1697ef0384231d333 (diff)
downloadlibplist-5ea6de69afcf11f2d2e59258cb055a5b1fdb5f82.tar.gz
libplist-5ea6de69afcf11f2d2e59258cb055a5b1fdb5f82.tar.bz2
C++: Use `free()` instead of `delete` for C things
Diffstat (limited to 'src')
-rw-r--r--src/Array.cpp2
-rw-r--r--src/Data.cpp6
-rw-r--r--src/Dictionary.cpp6
-rw-r--r--src/Key.cpp2
-rw-r--r--src/Structure.cpp4
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)
168 std::vector<Node*>::iterator it = _array.begin(); 168 std::vector<Node*>::iterator it = _array.begin();
169 it += pos; 169 it += pos;
170 _array.erase(it); 170 _array.erase(it);
171 delete node; 171 free(node);
172 } 172 }
173} 173}
174 174
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)
66 66
67std::vector<char> Data::GetValue() const 67std::vector<char> Data::GetValue() const
68{ 68{
69 char* buff = NULL;
70 uint64_t length = 0; 69 uint64_t length = 0;
71 plist_get_data_val(_node, &buff, &length); 70 const char* buff = plist_get_data_ptr(_node, &length);
72 std::vector<char> ret(buff, buff + length); 71 std::vector<char> ret(buff, buff + length);
73 delete buff;
74 return ret; 72 return ret;
75} 73}
76 74
77
78
79} // namespace PList 75} // 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,
40 plist_dict_next_item(node, it, &key, &subnode); 40 plist_dict_next_item(node, it, &key, &subnode);
41 if (key && subnode) 41 if (key && subnode)
42 map[std::string(key)] = Node::FromPlist(subnode, _this); 42 map[std::string(key)] = Node::FromPlist(subnode, _this);
43 delete key; 43 free(key);
44 } while (subnode); 44 } while (subnode);
45 free(it); 45 free(it);
46} 46}
@@ -176,9 +176,9 @@ void Dictionary::Remove(Node* node)
176 plist_dict_get_item_key(node->GetPlist(), &key); 176 plist_dict_get_item_key(node->GetPlist(), &key);
177 plist_dict_remove_item(_node, key); 177 plist_dict_remove_item(_node, key);
178 std::string skey = key; 178 std::string skey = key;
179 delete key; 179 free(key);
180 _map.erase(skey); 180 _map.erase(skey);
181 delete node; 181 free(node);
182 } 182 }
183} 183}
184 184
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
69 char* s = NULL; 69 char* s = NULL;
70 plist_get_key_val(_node, &s); 70 plist_get_key_val(_node, &s);
71 std::string ret = s ? s : ""; 71 std::string ret = s ? s : "";
72 delete s; 72 free(s);
73 return ret; 73 return ret;
74} 74}
75 75
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
57 uint32_t length = 0; 57 uint32_t length = 0;
58 plist_to_xml(_node, &xml, &length); 58 plist_to_xml(_node, &xml, &length);
59 std::string ret(xml, xml+length); 59 std::string ret(xml, xml+length);
60 delete xml; 60 free(xml);
61 return ret; 61 return ret;
62} 62}
63 63
@@ -67,7 +67,7 @@ std::vector<char> Structure::ToBin() const
67 uint32_t length = 0; 67 uint32_t length = 0;
68 plist_to_bin(_node, &bin, &length); 68 plist_to_bin(_node, &bin, &length);
69 std::vector<char> ret(bin, bin+length); 69 std::vector<char> ret(bin, bin+length);
70 delete bin; 70 free(bin);
71 return ret; 71 return ret;
72} 72}
73 73