mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Cleanup net_ifinfo
This commit is contained in:
parent
cbc8bab8e2
commit
191b233334
@ -73,7 +73,7 @@ bool net_ifinfo_new(net_ifinfo_t *list)
|
||||
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
|
||||
{
|
||||
char host[NI_MAXHOST];
|
||||
int s = 0;
|
||||
struct net_ifinfo_entry *ptr = NULL;
|
||||
|
||||
if (!ifa->ifa_addr)
|
||||
continue;
|
||||
@ -81,26 +81,23 @@ bool net_ifinfo_new(net_ifinfo_t *list)
|
||||
if (ifa->ifa_addr->sa_family != AF_INET)
|
||||
continue;
|
||||
|
||||
s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in),
|
||||
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
||||
|
||||
if (s != 0)
|
||||
if (getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in),
|
||||
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) != 0)
|
||||
goto error;
|
||||
|
||||
{
|
||||
struct net_ifinfo_entry *ptr = (struct net_ifinfo_entry*)
|
||||
realloc(list->entries, (k+1) * sizeof(struct net_ifinfo_entry));
|
||||
ptr = (struct net_ifinfo_entry*)
|
||||
realloc(list->entries, (k+1) * sizeof(struct net_ifinfo_entry));
|
||||
|
||||
if (!ptr)
|
||||
goto error;
|
||||
if (!ptr)
|
||||
goto error;
|
||||
|
||||
list->entries = ptr;
|
||||
}
|
||||
list->entries = ptr;
|
||||
|
||||
list->entries[k].name = strdup(ifa->ifa_name);
|
||||
list->entries[k].host = strdup(host);
|
||||
list->size = k + 1;
|
||||
|
||||
k++;
|
||||
list->size = k;
|
||||
}
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user