mirror of
https://github.com/libretro/RetroArch
synced 2025-04-15 14:42:27 +00:00
Minor cleanup
This commit is contained in:
parent
c7f839a7fd
commit
4092fd7e83
@ -327,10 +327,7 @@ bool net_http_connection_done(struct http_connection_t *conn)
|
||||
{
|
||||
int has_port = 0;
|
||||
|
||||
if (!conn)
|
||||
return false;
|
||||
|
||||
if (!conn->domain || !*conn->domain)
|
||||
if (!conn || !conn->domain || !*conn->domain)
|
||||
return false;
|
||||
|
||||
if (*conn->scan == ':')
|
||||
@ -357,7 +354,7 @@ bool net_http_connection_done(struct http_connection_t *conn)
|
||||
{
|
||||
/* domain followed by location - split off the location */
|
||||
/* site.com/path.html or site.com:80/path.html */
|
||||
*conn->scan = '\0';
|
||||
*conn->scan = '\0';
|
||||
conn->location = conn->scan + 1;
|
||||
return true;
|
||||
}
|
||||
@ -375,30 +372,28 @@ bool net_http_connection_done(struct http_connection_t *conn)
|
||||
if (!has_port)
|
||||
{
|
||||
/* if there wasn't a port, we have to expand the urlcopy so we can separate the two parts */
|
||||
size_t domain_len = strlen(conn->domain);
|
||||
size_t domain_len = strlen(conn->domain);
|
||||
size_t location_len = strlen(conn->scan);
|
||||
char* urlcopy = (char*)malloc(domain_len + location_len + 2);
|
||||
char* urlcopy = (char*)malloc(domain_len + location_len + 2);
|
||||
memcpy(urlcopy, conn->domain, domain_len);
|
||||
urlcopy[domain_len] = '\0';
|
||||
memcpy(urlcopy + domain_len + 1, conn->scan, location_len + 1);
|
||||
|
||||
free(conn->urlcopy);
|
||||
conn->domain = conn->urlcopy = urlcopy;
|
||||
conn->location = conn->scan = urlcopy + domain_len + 1;
|
||||
conn->domain = conn->urlcopy = urlcopy;
|
||||
conn->location = conn->scan = urlcopy + domain_len + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* there was a port, so overwriting the : will terminate the domain and we can just point at the ? */
|
||||
conn->location = conn->scan;
|
||||
conn->location = conn->scan;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid character after domain/port */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* invalid character after domain/port */
|
||||
return false;
|
||||
}
|
||||
|
||||
void net_http_connection_free(struct http_connection_t *conn)
|
||||
@ -430,7 +425,8 @@ void net_http_connection_free(struct http_connection_t *conn)
|
||||
free(conn);
|
||||
}
|
||||
|
||||
void net_http_connection_set_user_agent(struct http_connection_t* conn, const char* user_agent)
|
||||
void net_http_connection_set_user_agent(
|
||||
struct http_connection_t* conn, const char* user_agent)
|
||||
{
|
||||
if (conn->useragentcopy)
|
||||
free(conn->useragentcopy);
|
||||
|
Loading…
x
Reference in New Issue
Block a user