mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +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)
|
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
|
||||||
{
|
{
|
||||||
char host[NI_MAXHOST];
|
char host[NI_MAXHOST];
|
||||||
int s = 0;
|
struct net_ifinfo_entry *ptr = NULL;
|
||||||
|
|
||||||
if (!ifa->ifa_addr)
|
if (!ifa->ifa_addr)
|
||||||
continue;
|
continue;
|
||||||
@ -81,26 +81,23 @@ bool net_ifinfo_new(net_ifinfo_t *list)
|
|||||||
if (ifa->ifa_addr->sa_family != AF_INET)
|
if (ifa->ifa_addr->sa_family != AF_INET)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in),
|
if (getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in),
|
||||||
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
|
host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) != 0)
|
||||||
|
|
||||||
if (s != 0)
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
{
|
ptr = (struct net_ifinfo_entry*)
|
||||||
struct net_ifinfo_entry *ptr = (struct net_ifinfo_entry*)
|
|
||||||
realloc(list->entries, (k+1) * sizeof(struct net_ifinfo_entry));
|
realloc(list->entries, (k+1) * sizeof(struct net_ifinfo_entry));
|
||||||
|
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
list->entries = ptr;
|
list->entries = ptr;
|
||||||
}
|
|
||||||
|
|
||||||
list->entries[k].name = strdup(ifa->ifa_name);
|
list->entries[k].name = strdup(ifa->ifa_name);
|
||||||
list->entries[k].host = strdup(host);
|
list->entries[k].host = strdup(host);
|
||||||
|
list->size = k + 1;
|
||||||
|
|
||||||
k++;
|
k++;
|
||||||
list->size = k;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
freeifaddrs(ifaddr);
|
freeifaddrs(ifaddr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user