From b086d0612740978c1942c1c3a078d4a0b8ffffef Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 21 Dec 2020 22:09:42 -0800 Subject: [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 --- src/String.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/String.cpp') 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; } -- cgit v1.1-32-gdbae