(SIGAR-199) add arp_list_{create,grow,destroy} functions

This commit is contained in:
Doug MacEachern 2010-01-18 14:57:23 -08:00
parent b5cf0dbef4
commit 6bea72a540
1 changed files with 30 additions and 0 deletions

View File

@ -956,6 +956,36 @@ int sigar_tcp_curr_estab(sigar_t *sigar, sigar_tcp_t *tcp)
return sigar_net_connection_walk(&walker); return sigar_net_connection_walk(&walker);
} }
int sigar_arp_list_create(sigar_arp_list_t *arplist)
{
arplist->number = 0;
arplist->size = SIGAR_ARP_LIST_MAX;
arplist->data = malloc(sizeof(*(arplist->data)) *
arplist->size);
return SIGAR_OK;
}
int sigar_arp_list_grow(sigar_arp_list_t *arplist)
{
arplist->data = realloc(arplist->data,
sizeof(*(arplist->data)) *
(arplist->size + SIGAR_ARP_LIST_MAX));
arplist->size += SIGAR_ARP_LIST_MAX;
return SIGAR_OK;
}
SIGAR_DECLARE(int) sigar_arp_list_destroy(sigar_t *sigar,
sigar_arp_list_t *arplist)
{
if (arplist->size) {
free(arplist->data);
arplist->number = arplist->size = 0;
}
return SIGAR_OK;
}
int sigar_who_list_create(sigar_who_list_t *wholist) int sigar_who_list_create(sigar_who_list_t *wholist)
{ {
wholist->number = 0; wholist->number = 0;