summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoritojun <>2000-02-23 15:39:53 +0000
committeritojun <>2000-02-23 15:39:53 +0000
commitc8f8fcd5d63235b42dbae0cf029c1939e98d40b5 (patch)
treebd2dfd07687b3962f47c6a0e7e65ff610f45d00d
parentebd32d3382e8e38694e45f4ca5a83fed5ad68d76 (diff)
downloadopenbsd-c8f8fcd5d63235b42dbae0cf029c1939e98d40b5.tar.gz
openbsd-c8f8fcd5d63235b42dbae0cf029c1939e98d40b5.tar.bz2
openbsd-c8f8fcd5d63235b42dbae0cf029c1939e98d40b5.zip
add freeifaddrs(3), which reclaims region allocated by getifaddrs(3).
in sync with kame and bsdi.
-rw-r--r--src/lib/libc/net/Makefile.inc3
-rw-r--r--src/lib/libc/net/getifaddrs.39
-rw-r--r--src/lib/libc/net/getifaddrs.c10
3 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc
index 7504a3e195..641d612105 100644
--- a/src/lib/libc/net/Makefile.inc
+++ b/src/lib/libc/net/Makefile.inc
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile.inc,v 1.29 2000/02/23 06:55:58 itojun Exp $ 1# $OpenBSD: Makefile.inc,v 1.30 2000/02/23 15:39:53 itojun Exp $
2 2
3# net sources 3# net sources
4.PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net ${LIBCSRCDIR}/net 4.PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net ${LIBCSRCDIR}/net
@@ -47,6 +47,7 @@ MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \
47 gethostbyname.3 sethostent.3 gethostbyname.3 gethostent.3 \ 47 gethostbyname.3 sethostent.3 gethostbyname.3 gethostent.3 \
48 gethostbyname.3 herror.3 gethostbyname.3 gethostbyname2.3 \ 48 gethostbyname.3 herror.3 gethostbyname.3 gethostbyname2.3 \
49 gethostbyname.3 hstrerror.3 49 gethostbyname.3 hstrerror.3
50MLINKS+=getifaddrs.3 freeifaddrs.3
50MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \ 51MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \
51 getnetent.3 getnetbyname.3 getnetent.3 setnetent.3 52 getnetent.3 getnetbyname.3 getnetent.3 setnetent.3
52MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \ 53MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \
diff --git a/src/lib/libc/net/getifaddrs.3 b/src/lib/libc/net/getifaddrs.3
index 68c12b552a..c081a0602c 100644
--- a/src/lib/libc/net/getifaddrs.3
+++ b/src/lib/libc/net/getifaddrs.3
@@ -1,5 +1,5 @@
1.\" $OpenBSD: getifaddrs.3,v 1.1 2000/02/23 06:55:58 itojun Exp $ 1.\" $OpenBSD: getifaddrs.3,v 1.2 2000/02/23 15:39:53 itojun Exp $
2.\" BSDI getifaddrs.3,v 2.4 1999/03/15 20:57:20 jch Exp 2.\" BSDI getifaddrs.3,v 2.5 2000/02/23 14:51:59 dab Exp
3.\" 3.\"
4.\" Copyright (c) 1995, 1999 4.\" Copyright (c) 1995, 1999
5.\" Berkeley Software Design, Inc. All rights reserved. 5.\" Berkeley Software Design, Inc. All rights reserved.
@@ -32,6 +32,8 @@
32.Fd #include <ifaddrs.h> 32.Fd #include <ifaddrs.h>
33.Ft int 33.Ft int
34.Fn getifaddrs "struct ifaddrs **ifap" 34.Fn getifaddrs "struct ifaddrs **ifap"
35.Ft void
36.Fn freeifaddrs "struct ifaddrs *ifp"
35.Sh DESCRIPTION 37.Sh DESCRIPTION
36The 38The
37.Fn getifaddrs 39.Fn getifaddrs
@@ -120,8 +122,7 @@ which contains per-address interface statistics.
120The data returned by 122The data returned by
121.Fn getifaddrs 123.Fn getifaddrs
122is dynamically allocated and should be freed using 124is dynamically allocated and should be freed using
123.Fn free 125.Fn freeifaddrs
124.Pq see Xr free 3
125when no longer needed. 126when no longer needed.
126.Sh RETURN VALUES 127.Sh RETURN VALUES
127Upon successful completion, a value of 0 is returned. 128Upon successful completion, a value of 0 is returned.
diff --git a/src/lib/libc/net/getifaddrs.c b/src/lib/libc/net/getifaddrs.c
index 9537405667..828d2da215 100644
--- a/src/lib/libc/net/getifaddrs.c
+++ b/src/lib/libc/net/getifaddrs.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: getifaddrs.c,v 1.1 2000/02/23 06:55:58 itojun Exp $ */ 1/* $OpenBSD: getifaddrs.c,v 1.2 2000/02/23 15:39:53 itojun Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995, 1999 4 * Copyright (c) 1995, 1999
@@ -22,7 +22,7 @@
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE. 23 * SUCH DAMAGE.
24 * 24 *
25 * BSDI getifaddrs.c,v 2.11 1999/03/15 20:57:20 jch Exp 25 * BSDI getifaddrs.c,v 2.12 2000/02/23 14:51:59 dab Exp
26 */ 26 */
27/* 27/*
28 * NOTE: SIOCGIFCONF case is not LP64 friendly. it also does not perform 28 * NOTE: SIOCGIFCONF case is not LP64 friendly. it also does not perform
@@ -371,3 +371,9 @@ getifaddrs(struct ifaddrs **pif)
371 } 371 }
372 return (0); 372 return (0);
373} 373}
374
375void
376freeifaddrs(struct ifaddrs *ifp)
377{
378 free(ifp);
379}