From 4b9363d8e48c8486517696a01193a6ad27585473 Mon Sep 17 00:00:00 2001 From: itojun Date: Wed, 23 Feb 2000 15:29:18 +0000 Subject: [PATCH] add freeifaddrs(), which reclaims region allocated by getifaddrs(). in sync with kame and bsdi. --- include/ifaddrs.h | 5 +++-- lib/libc/net/getifaddrs.3 | 9 +++++---- lib/libc/net/getifaddrs.c | 10 ++++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/ifaddrs.h b/include/ifaddrs.h index 05e3931860ea..17162b7089a4 100644 --- a/include/ifaddrs.h +++ b/include/ifaddrs.h @@ -1,4 +1,4 @@ -/* $NetBSD: ifaddrs.h,v 1.1 2000/02/23 06:57:47 itojun Exp $ */ +/* $NetBSD: ifaddrs.h,v 1.2 2000/02/23 15:29:19 itojun Exp $ */ /* * Copyright (c) 1995, 1999 @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * BSDI ifaddrs.h,v 2.4 1999/03/15 20:59:28 jch Exp + * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp */ #ifndef _IFADDRS_H_ @@ -50,6 +50,7 @@ struct ifaddrs { __BEGIN_DECLS extern int getifaddrs __P((struct ifaddrs **)); +extern void freeifaddrs __P((struct ifaddrs *)); __END_DECLS #endif diff --git a/lib/libc/net/getifaddrs.3 b/lib/libc/net/getifaddrs.3 index fb64e77aff37..bf30dc6f72e3 100644 --- a/lib/libc/net/getifaddrs.3 +++ b/lib/libc/net/getifaddrs.3 @@ -1,5 +1,5 @@ -.\" $NetBSD: getifaddrs.3,v 1.1 2000/02/23 06:57:46 itojun Exp $ -.\" BSDI getifaddrs.3,v 2.4 1999/03/15 20:57:20 jch Exp +.\" $NetBSD: getifaddrs.3,v 1.2 2000/02/23 15:29:18 itojun Exp $ +.\" BSDI getifaddrs.3,v 2.5 2000/02/23 14:51:59 dab Exp .\" .\" Copyright (c) 1995, 1999 .\" Berkeley Software Design, Inc. All rights reserved. @@ -32,6 +32,8 @@ .Fd #include .Ft int .Fn getifaddrs "struct ifaddrs **ifap" +.Ft void +.Fn freeifaddrs "struct ifaddrs *ifp" .Sh DESCRIPTION The .Fn getifaddrs @@ -120,8 +122,7 @@ which contains per-address interface statistics. The data returned by .Fn getifaddrs is dynamically allocated and should be freed using -.Fn free -.Pq see Xr free 3 +.Fn freeifaddrs when no longer needed. .Sh RETURN VALUES Upon successful completion, a value of 0 is returned. diff --git a/lib/libc/net/getifaddrs.c b/lib/libc/net/getifaddrs.c index c400393cd971..c20cc56fdd67 100644 --- a/lib/libc/net/getifaddrs.c +++ b/lib/libc/net/getifaddrs.c @@ -1,4 +1,4 @@ -/* $NetBSD: getifaddrs.c,v 1.1 2000/02/23 06:57:46 itojun Exp $ */ +/* $NetBSD: getifaddrs.c,v 1.2 2000/02/23 15:29:18 itojun Exp $ */ /* * Copyright (c) 1995, 1999 @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * BSDI getifaddrs.c,v 2.11 1999/03/15 20:57:20 jch Exp + * BSDI getifaddrs.c,v 2.12 2000/02/23 14:51:59 dab Exp */ #include #include @@ -367,3 +367,9 @@ getifaddrs(struct ifaddrs **pif) } return (0); } + +void +freeifaddrs(struct ifaddrs *ifp) +{ + free(ifp); +}