diff options
author | Rosen Penev | 2020-12-21 22:09:42 -0800 |
---|---|---|
committer | Nikias Bassen | 2021-06-22 01:29:05 +0200 |
commit | b086d0612740978c1942c1c3a078d4a0b8ffffef (patch) | |
tree | 46484950e8e6dbf2fb5d773a84b5bb73fc313bf7 /src/Key.cpp | |
parent | 526c10436caa894fb6139f4e6c0f73eebfa858ea (diff) | |
download | libplist-b086d0612740978c1942c1c3a078d4a0b8ffffef.tar.gz libplist-b086d0612740978c1942c1c3a078d4a0b8ffffef.tar.bz2 |
[clang-tidy] cpp: Replace free with delete
It's the C++ way. It also avoids having to check for NULL.
Found with cppcoreguidelines-owning-memory
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'src/Key.cpp')
-rw-r--r-- | src/Key.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
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; } |