db/upnp: free responses manually

This commit is contained in:
Max Kellermann 2014-01-22 21:09:05 +01:00
parent 7573d4e1ba
commit bf9352fb26

View File

@ -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 static bool
ReadResultTag(UPnPDirContent &dirbuf, IXML_Document *response, Error &error) ReadResultTag(UPnPDirContent &dirbuf, IXML_Document *response, Error &error)
{ {
@ -106,8 +94,6 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
return false; return false;
} }
DirBResFree cleaner(&response);
const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned"); const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned");
didreadp = value != nullptr didreadp = value != nullptr
? ParseUnsigned(value) ? ParseUnsigned(value)
@ -117,10 +103,9 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
if (value != nullptr) if (value != nullptr)
totalp = ParseUnsigned(value); totalp = ParseUnsigned(value);
if (!ReadResultTag(dirbuf, response, error)) bool success = ReadResultTag(dirbuf, response, error);
return false; ixmlDocument_free(response);
return success;
return true;
} }
bool bool
@ -183,8 +168,6 @@ ContentDirectoryService::search(UpnpClient_Handle hdl,
return false; return false;
} }
DirBResFree cleaner(&response);
const char *value = const char *value =
ixmlwrap::getFirstElementValue(response, "NumberReturned"); ixmlwrap::getFirstElementValue(response, "NumberReturned");
const unsigned count = value != nullptr const unsigned count = value != nullptr
@ -197,7 +180,9 @@ ContentDirectoryService::search(UpnpClient_Handle hdl,
if (value != nullptr) if (value != nullptr)
total = ParseUnsigned(value); total = ParseUnsigned(value);
if (!ReadResultTag(dirbuf, response, error)) bool success = ReadResultTag(dirbuf, response, error);
ixmlDocument_free(response);
if (!success)
return false; return false;
if (count == 0) if (count == 0)