Skip to content

Commit 5ea6de6

Browse files
committed
C++: Use free() instead of delete for C things
1 parent d40f03e commit 5ea6de6

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

src/Array.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void Array::Remove(Node* node)
168168
std::vector<Node*>::iterator it = _array.begin();
169169
it += pos;
170170
_array.erase(it);
171-
delete node;
171+
free(node);
172172
}
173173
}
174174

src/Data.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@ void Data::SetValue(const std::vector<char>& buff)
6666

6767
std::vector<char> Data::GetValue() const
6868
{
69-
char* buff = NULL;
7069
uint64_t length = 0;
71-
plist_get_data_val(_node, &buff, &length);
70+
const char* buff = plist_get_data_ptr(_node, &length);
7271
std::vector<char> ret(buff, buff + length);
73-
delete buff;
7472
return ret;
7573
}
7674

77-
78-
7975
} // namespace PList

src/Dictionary.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void dictionary_fill(Dictionary *_this, std::map<std::string,Node*> &map,
4040
plist_dict_next_item(node, it, &key, &subnode);
4141
if (key && subnode)
4242
map[std::string(key)] = Node::FromPlist(subnode, _this);
43-
delete key;
43+
free(key);
4444
} while (subnode);
4545
free(it);
4646
}
@@ -176,9 +176,9 @@ void Dictionary::Remove(Node* node)
176176
plist_dict_get_item_key(node->GetPlist(), &key);
177177
plist_dict_remove_item(_node, key);
178178
std::string skey = key;
179-
delete key;
179+
free(key);
180180
_map.erase(skey);
181-
delete node;
181+
free(node);
182182
}
183183
}
184184

src/Key.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ std::string Key::GetValue() const
6969
char* s = NULL;
7070
plist_get_key_val(_node, &s);
7171
std::string ret = s ? s : "";
72-
delete s;
72+
free(s);
7373
return ret;
7474
}
7575

src/Structure.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ std::string Structure::ToXml() const
5757
uint32_t length = 0;
5858
plist_to_xml(_node, &xml, &length);
5959
std::string ret(xml, xml+length);
60-
delete xml;
60+
free(xml);
6161
return ret;
6262
}
6363

@@ -67,7 +67,7 @@ std::vector<char> Structure::ToBin() const
6767
uint32_t length = 0;
6868
plist_to_bin(_node, &bin, &length);
6969
std::vector<char> ret(bin, bin+length);
70-
delete bin;
70+
free(bin);
7171
return ret;
7272
}
7373

0 commit comments

Comments
 (0)