diff options
Diffstat (limited to 'src/Key.cpp')
-rw-r--r-- | src/Key.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/Key.cpp b/src/Key.cpp index ed0c0c6..79265d5 100644 --- a/src/Key.cpp +++ b/src/Key.cpp @@ -18,7 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <stdlib.h> +#include <cstdlib> +#include "plist.h" #include <plist/Key.h> namespace PList @@ -32,12 +33,12 @@ Key::Key(plist_t node, Node* parent) : Node(node, parent) { } -Key::Key(const PList::Key& k) : Node(PLIST_UINT) +Key::Key(const PList::Key& k) : Node(PLIST_INT) { plist_set_key_val(_node, k.GetValue().c_str()); } -Key& Key::operator=(PList::Key& k) +Key& Key::operator=(const PList::Key& k) { plist_free(_node); _node = plist_copy(k.GetPlist()); @@ -67,14 +68,9 @@ 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; } -}; +} // namespace PList |