Added the convenience function UpnpResolveURL2() to upnptools.c.

This function avoids some unecessary memory allocation.
The memory alloc'd by this function must be freed later by the caller.
This commit is contained in:
Marcelo Roberto Jimenez
2010-11-15 01:01:07 -02:00
parent 2dd19e5894
commit 8651174861
3 changed files with 52 additions and 3 deletions

View File

@@ -147,18 +147,36 @@ int UpnpResolveURL(
int ret = UPNP_E_SUCCESS;
char *tempRel = NULL;
if (RelURL == NULL) {
if (!RelURL) {
ret = UPNP_E_INVALID_PARAM;
goto ExitFunction;
}
tempRel = resolve_rel_url((char *)BaseURL, (char *)RelURL);
if (tempRel) {
strcpy(AbsURL, tempRel);
free(tempRel);
} else {
} else
ret = UPNP_E_INVALID_URL;
ExitFunction:
return UPNP_E_SUCCESS;
}
int UpnpResolveURL2(
const char *BaseURL,
const char *RelURL,
char **AbsURL)
{
int ret = UPNP_E_SUCCESS;
if (!RelURL) {
ret = UPNP_E_INVALID_PARAM;
goto ExitFunction;
}
*AbsURL = resolve_rel_url((char *)BaseURL, (char *)RelURL);
if (!*AbsURL)
ret = UPNP_E_INVALID_URL;
ExitFunction:
return UPNP_E_SUCCESS;