summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2014-07-15 03:28:37 +0000
committerpfg <pfg@FreeBSD.org>2014-07-15 03:28:37 +0000
commitb2edcea2f09e8ae340319af5a1ef2fd254173fe7 (patch)
treeacb501b447166438c161356ee6d202bca7b41f54 /lib
parent6a45f468c198569c30ee178595ac28509cb3ba60 (diff)
downloadFreeBSD-src-b2edcea2f09e8ae340319af5a1ef2fd254173fe7.zip
FreeBSD-src-b2edcea2f09e8ae340319af5a1ef2fd254173fe7.tar.gz
libc/stdlib: Minor cleanups to code originating in NetBSD
Mostly ANSIfication and typos. Obtained from: NetBSD MFC after: 5 days
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/hcreate.c6
-rw-r--r--lib/libc/stdlib/tsearch.c13
-rw-r--r--lib/libc/stdlib/twalk.c17
3 files changed, 14 insertions, 22 deletions
diff --git a/lib/libc/stdlib/hcreate.c b/lib/libc/stdlib/hcreate.c
index c68fe1b..cfcd115 100644
--- a/lib/libc/stdlib/hcreate.c
+++ b/lib/libc/stdlib/hcreate.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hcreate.c,v 1.2 2001/02/19 21:26:04 ross Exp $ */
+/* $NetBSD: hcreate.c,v 1.6 2008/07/21 12:05:43 lukem Exp $ */
/*
* Copyright (c) 2001 Christopher G. Demetriou
@@ -15,7 +15,7 @@
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the
- * NetBSD Project. See http://www.netbsd.org/ for
+ * NetBSD Project. See http://www.NetBSD.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
@@ -49,7 +49,7 @@
#include <sys/cdefs.h>
#if 0
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: hcreate.c,v 1.2 2001/02/19 21:26:04 ross Exp $");
+__RCSID("$NetBSD: hcreate.c,v 1.6 2008/07/21 12:05:43 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#endif
__FBSDID("$FreeBSD$");
diff --git a/lib/libc/stdlib/tsearch.c b/lib/libc/stdlib/tsearch.c
index 149c2bb..16bbf7c 100644
--- a/lib/libc/stdlib/tsearch.c
+++ b/lib/libc/stdlib/tsearch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $ */
+/* $NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
/*
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
@@ -14,7 +14,7 @@
#include <sys/cdefs.h>
#if 0
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $");
+__RCSID("$NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#endif
__FBSDID("$FreeBSD$");
@@ -25,10 +25,8 @@ __FBSDID("$FreeBSD$");
/* find or insert datum into search tree */
void *
-tsearch(vkey, vrootp, compar)
- const void *vkey; /* key to be located */
- void **vrootp; /* address of tree root */
- int (*compar)(const void *, const void *);
+tsearch(const void *vkey, void **vrootp,
+ int (*compar)(const void *, const void *))
{
node_t *q;
node_t **rootp = (node_t **)vrootp;
@@ -50,8 +48,7 @@ tsearch(vkey, vrootp, compar)
q = malloc(sizeof(node_t)); /* T5: key not found */
if (q != 0) { /* make new node */
*rootp = q; /* link new node to old */
- /* LINTED const castaway ok */
- q->key = (void *)vkey; /* initialize new node */
+ q->key = __DECONST(void *, vkey);/* initialize new node */
q->llink = q->rlink = NULL;
}
return q;
diff --git a/lib/libc/stdlib/twalk.c b/lib/libc/stdlib/twalk.c
index 55f220f3..7acee41 100644
--- a/lib/libc/stdlib/twalk.c
+++ b/lib/libc/stdlib/twalk.c
@@ -1,4 +1,4 @@
-/* $NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $ */
+/* $NetBSD: twalk.c,v 1.4 2012/03/20 16:38:45 matt Exp $ */
/*
* Tree search generalized from Knuth (6.2.2) Algorithm T just like
@@ -14,7 +14,7 @@
#include <sys/cdefs.h>
#if 0
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $");
+__RCSID("$NetBSD: twalk.c,v 1.4 2012/03/20 16:38:45 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#endif
__FBSDID("$FreeBSD$");
@@ -23,15 +23,12 @@ __FBSDID("$FreeBSD$");
#include <search.h>
#include <stdlib.h>
-static void trecurse(const node_t *,
- void (*action)(const void *, VISIT, int), int level);
+typedef void (*cmp_fn_t)(const void *, VISIT, int);
/* Walk the nodes of a tree */
static void
-trecurse(root, action, level)
- const node_t *root; /* Root of the tree to be walked */
- void (*action)(const void *, VISIT, int);
- int level;
+trecurse(const node_t *root, /* Root of the tree to be walked */
+ cmp_fn_t action, int level)
{
if (root->llink == NULL && root->rlink == NULL)
@@ -49,9 +46,7 @@ trecurse(root, action, level)
/* Walk the nodes of a tree */
void
-twalk(vroot, action)
- const void *vroot; /* Root of the tree to be walked */
- void (*action)(const void *, VISIT, int);
+twalk(const void *vroot, cmp_fn_t action) /* Root of the tree to be walked */
{
if (vroot != NULL && action != NULL)
trecurse(vroot, action, 0);
OpenPOWER on IntegriCloud