Add util.hpp
First utility is a malloc deleter for use with smart pointers.
Change-Id: I78d1723608048cc64d81891d5aa6791eaf3343e5
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index 66e48a8..dfda21f 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -23,6 +23,7 @@
#include "hwmon.hpp"
#include "sysfs.hpp"
#include "mainloop.hpp"
+#include "util.hpp"
using namespace std::literals::chrono_literals;
@@ -151,15 +152,8 @@
}
{
- struct Free
- {
- void operator()(char* ptr) const
- {
- free(ptr);
- }
- };
-
- auto copy = std::unique_ptr<char, Free>(strdup(_path.c_str()));
+ auto copy = std::unique_ptr<char, phosphor::utility::Free<char>>(strdup(
+ _path.c_str()));
auto busname = std::string(_prefix) + '.' + basename(copy.get());
_bus.request_name(busname.c_str());
}