From 6bea72a540e4924c8d7307b8e1524742b15fbef5 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 18 Jan 2010 14:57:23 -0800 Subject: [PATCH] (SIGAR-199) add arp_list_{create,grow,destroy} functions --- src/sigar.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/sigar.c b/src/sigar.c index 15801836..e8aaa084 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -956,6 +956,36 @@ int sigar_tcp_curr_estab(sigar_t *sigar, sigar_tcp_t *tcp) 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) { wholist->number = 0;