netlink: Use function views
These provide type erasure without requiring us to copy anything into
function objects.
Change-Id: I4dcddb54b1b78d36945ac4c976a1be55bed1c0f9
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/netlink.cpp b/src/netlink.cpp
index 011cf95..4ac7c8b 100644
--- a/src/netlink.cpp
+++ b/src/netlink.cpp
@@ -19,7 +19,7 @@
namespace detail
{
-void processMsg(std::string_view& msgs, bool& done, const ReceiveCallback& cb)
+void processMsg(std::string_view& msgs, bool& done, ReceiveCallback cb)
{
// Parse and update the message buffer
auto hdr = stdplus::raw::copyFrom<nlmsghdr>(msgs);
@@ -73,7 +73,7 @@
}
}
-static void receive(int sock, const ReceiveCallback& cb)
+static void receive(int sock, ReceiveCallback cb)
{
// We need to make sure we have enough room for an entire packet otherwise
// it gets truncated. The netlink docs guarantee packets will not exceed 8K
@@ -156,8 +156,7 @@
return sock;
}
-void performRequest(int protocol, void* data, size_t size,
- const ReceiveCallback& cb)
+void performRequest(int protocol, void* data, size_t size, ReceiveCallback cb)
{
auto sock = makeSocket(protocol);
requestSend(sock.get(), data, size);