summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
70 uint64_t length = 0; 70 uint64_t length = 0;
71 plist_get_data_val(_node, &buff, &length); 71 plist_get_data_val(_node, &buff, &length);
72 std::vector<char> ret(buff, buff + length); 72 std::vector<char> ret(buff, buff + length);
73 free(buff); 73 delete buff;
74 return ret; 74 return ret;
75} 75}
76 76
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,
39 plist_dict_next_item(node, it, &key, &subnode); 39 plist_dict_next_item(node, it, &key, &subnode);
40 if (key && subnode) 40 if (key && subnode)
41 map[std::string(key)] = Node::FromPlist(subnode, _this); 41 map[std::string(key)] = Node::FromPlist(subnode, _this);
42 free(key); 42 delete key;
43 } while (subnode); 43 } while (subnode);
44 free(it); 44 free(it);
45} 45}
@@ -156,7 +156,7 @@ void Dictionary::Remove(Node* node)
156 plist_dict_get_item_key(node->GetPlist(), &key); 156 plist_dict_get_item_key(node->GetPlist(), &key);
157 plist_dict_remove_item(_node, key); 157 plist_dict_remove_item(_node, key);
158 std::string skey = key; 158 std::string skey = key;
159 free(key); 159 delete key;
160 _map.erase(skey); 160 _map.erase(skey);
161 delete node; 161 delete node;
162 } 162 }
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
67{ 67{
68 char* s = NULL; 68 char* s = NULL;
69 plist_get_key_val(_node, &s); 69 plist_get_key_val(_node, &s);
70 std::string ret; 70 std::string ret = s ? s : "";
71 if (s) { 71 delete s;
72 ret = s;
73 free(s);
74 } else {
75 ret = "";
76 }
77 return ret; 72 return ret;
78} 73}
79 74
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
67{ 67{
68 char* s = NULL; 68 char* s = NULL;
69 plist_get_string_val(_node, &s); 69 plist_get_string_val(_node, &s);
70 std::string ret; 70 std::string ret = s ? s : "";
71 if (s) { 71 delete s;
72 ret = s;
73 free(s);
74 } else {
75 ret = "";
76 }
77 return ret; 72 return ret;
78} 73}
79 74
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
56 uint32_t length = 0; 56 uint32_t length = 0;
57 plist_to_xml(_node, &xml, &length); 57 plist_to_xml(_node, &xml, &length);
58 std::string ret(xml, xml+length); 58 std::string ret(xml, xml+length);
59 free(xml); 59 delete xml;
60 return ret; 60 return ret;
61} 61}
62 62
@@ -66,7 +66,7 @@ std::vector<char> Structure::ToBin() const
66 uint32_t length = 0; 66 uint32_t length = 0;
67 plist_to_bin(_node, &bin, &length); 67 plist_to_bin(_node, &bin, &length);
68 std::vector<char> ret(bin, bin+length); 68 std::vector<char> ret(bin, bin+length);
69 free(bin); 69 delete bin;
70 return ret; 70 return ret;
71} 71}
72 72