From 224d51161668a479680a2d03c3f9aa2bd5a5de6f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 6 Feb 2016 22:26:14 +0100 Subject: [PATCH] upnp/Discovery: use std::unique_ptr in WorkQueue --- src/lib/upnp/Discovery.cxx | 4 +--- src/lib/upnp/Discovery.hxx | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index bcbae6c87..6a761004d 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -111,7 +111,7 @@ inline void UPnPDeviceDirectory::Explore() { for (;;) { - DiscoveredTask *tsk = 0; + std::unique_ptr tsk; if (!queue.take(tsk)) { queue.workerExit(); return; @@ -138,14 +138,12 @@ UPnPDeviceDirectory::Explore() Error error2; bool success = d.Parse(tsk->url, buf, error2); if (!success) { - delete tsk; LogError(error2); continue; } } LockAdd(std::move(d)); - delete tsk; } } diff --git a/src/lib/upnp/Discovery.hxx b/src/lib/upnp/Discovery.hxx index 1cf82b77e..94c93c678 100644 --- a/src/lib/upnp/Discovery.hxx +++ b/src/lib/upnp/Discovery.hxx @@ -32,6 +32,7 @@ #include #include #include +#include class ContentDirectoryService; @@ -97,7 +98,7 @@ class UPnPDeviceDirectory final : UpnpCallback { Mutex mutex; std::list directories; - WorkQueue queue; + WorkQueue> queue; /** * The UPnP device search timeout, which should actually be