Use unique_ptr instead of calling free directly
Seems kind of silly, but sure, whatever you say clang-tidy.
Change-Id: Ieefaf3ee9d18eeee0d02ae8b2cd2873b52741cb6
diff --git a/src/yang_access.cpp b/src/yang_access.cpp
index 7ca30a2..8277ef1 100644
--- a/src/yang_access.cpp
+++ b/src/yang_access.cpp
@@ -267,10 +267,10 @@
{
char* output;
lyd_print_mem(&output, m_datastore.get(), format == DataFormat::Xml ? LYD_XML : LYD_JSON, LYP_WITHSIBLINGS | LYP_FORMAT);
+ std::unique_ptr<char, decltype(&free)> deleter{output, free};
if (output) {
std::string res = output;
- free(output);
return res;
}
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 575e241..711cdbd 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -398,7 +398,7 @@
};
auto deleter = [](void* data) {
- free(data);
+ free(data); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc)
};
m_context->add_missing_module_callback(lambda, deleter);
}