summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Data.cpp2
-rw-r--r--src/Dictionary.cpp4
-rw-r--r--src/Key.cpp9
-rw-r--r--src/String.cpp9
-rw-r--r--src/Structure.cpp4
5 files changed, 9 insertions, 19 deletions
diff --git a/src/Data.cpp b/src/Data.cpp
index 4515388..a96fc50 100644
--- a/src/Data.cpp
+++ b/src/Data.cpp
@@ -70,7 +70,7 @@ std::vector<char> Data::GetValue() const
uint64_t length = 0;
plist_get_data_val(_node, &buff, &length);
std::vector<char> ret(buff, buff + length);
- free(buff);
+ delete buff;
return ret;
}
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp
index 20e9710..ea04e81 100644
--- a/src/Dictionary.cpp
+++ b/src/Dictionary.cpp
@@ -39,7 +39,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);
- free(key);
+ delete key;
} while (subnode);
free(it);
}
@@ -156,7 +156,7 @@ void Dictionary::Remove(Node* node)
plist_dict_get_item_key(node->GetPlist(), &key);
plist_dict_remove_item(_node, key);
std::string skey = key;
- free(key);
+ delete key;
_map.erase(skey);
delete node;
}
diff --git a/src/Key.cpp b/src/Key.cpp
index 8ba497a..5d7d372 100644
--- a/src/Key.cpp
+++ b/src/Key.cpp
@@ -67,13 +67,8 @@ std::string Key::GetValue() const
{
char* s = NULL;
plist_get_key_val(_node, &s);
- std::string ret;
- if (s) {
- ret = s;
- free(s);
- } else {
- ret = "";
- }
+ std::string ret = s ? s : "";
+ delete s;
return ret;
}
diff --git a/src/String.cpp b/src/String.cpp
index cd4f98f..06b61ba 100644
--- a/src/String.cpp
+++ b/src/String.cpp
@@ -67,13 +67,8 @@ std::string String::GetValue() const
{
char* s = NULL;
plist_get_string_val(_node, &s);
- std::string ret;
- if (s) {
- ret = s;
- free(s);
- } else {
- ret = "";
- }
+ std::string ret = s ? s : "";
+ delete s;
return ret;
}
diff --git a/src/Structure.cpp b/src/Structure.cpp
index 9445c23..4be4e7d 100644
--- a/src/Structure.cpp
+++ b/src/Structure.cpp
@@ -56,7 +56,7 @@ std::string Structure::ToXml() const
uint32_t length = 0;
plist_to_xml(_node, &xml, &length);
std::string ret(xml, xml+length);
- free(xml);
+ delete xml;
return ret;
}
@@ -66,7 +66,7 @@ std::vector<char> Structure::ToBin() const
uint32_t length = 0;
plist_to_bin(_node, &bin, &length);
std::vector<char> ret(bin, bin+length);
- free(bin);
+ delete bin;
return ret;
}