diff options
author | Max Kellermann <max@duempel.org> | 2014-01-22 21:09:05 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-22 21:33:54 +0100 |
commit | bf9352fb268384f428332b0aabeaefcc9c1e4843 (patch) | |
tree | 33b2b6f4117b3bdaae87a6e0022dd6412cadb159 /src/db/upnp | |
parent | 7573d4e1ba2de203021201818d25d003213cefa8 (diff) | |
download | mpd-bf9352fb268384f428332b0aabeaefcc9c1e4843.tar.gz mpd-bf9352fb268384f428332b0aabeaefcc9c1e4843.tar.xz mpd-bf9352fb268384f428332b0aabeaefcc9c1e4843.zip |
db/upnp: free responses manually
Diffstat (limited to '')
-rw-r--r-- | src/db/upnp/ContentDirectoryService.cxx | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/db/upnp/ContentDirectoryService.cxx b/src/db/upnp/ContentDirectoryService.cxx index 9068b2e30..d4e5fec59 100644 --- a/src/db/upnp/ContentDirectoryService.cxx +++ b/src/db/upnp/ContentDirectoryService.cxx @@ -48,18 +48,6 @@ ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device, } } -class DirBResFree { -public: - IXML_Document **rspp; - DirBResFree(IXML_Document **_rspp) - :rspp(_rspp) {} - ~DirBResFree() - { - if (*rspp) - ixmlDocument_free(*rspp); - } -}; - static bool ReadResultTag(UPnPDirContent &dirbuf, IXML_Document *response, Error &error) { @@ -106,8 +94,6 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl, return false; } - DirBResFree cleaner(&response); - const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned"); didreadp = value != nullptr ? ParseUnsigned(value) @@ -117,10 +103,9 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl, if (value != nullptr) totalp = ParseUnsigned(value); - if (!ReadResultTag(dirbuf, response, error)) - return false; - - return true; + bool success = ReadResultTag(dirbuf, response, error); + ixmlDocument_free(response); + return success; } bool @@ -183,8 +168,6 @@ ContentDirectoryService::search(UpnpClient_Handle hdl, return false; } - DirBResFree cleaner(&response); - const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned"); const unsigned count = value != nullptr @@ -197,7 +180,9 @@ ContentDirectoryService::search(UpnpClient_Handle hdl, if (value != nullptr) total = ParseUnsigned(value); - if (!ReadResultTag(dirbuf, response, error)) + bool success = ReadResultTag(dirbuf, response, error); + ixmlDocument_free(response); + if (!success) return false; if (count == 0) |