summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-11-29 12:17:13 +0000
committerharti <harti@FreeBSD.org>2004-11-29 12:17:13 +0000
commite0db77dfe1c468c3507c5a1c4dfa51498f9731b7 (patch)
treebffaf3c562c2751af595939dcee49e7e71a0edfb /usr.bin
parent1de8c442ef554860403a45d1f98f699cbe0de649 (diff)
downloadFreeBSD-src-e0db77dfe1c468c3507c5a1c4dfa51498f9731b7.zip
FreeBSD-src-e0db77dfe1c468c3507c5a1c4dfa51498f9731b7.tar.gz
Use typedefs for the types of the functions that are passed as arguments
to the list functions for better readability. Submitted by: Max Okumoto <okumoto@ucsd.edu>
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/for.c2
-rw-r--r--usr.bin/make/lst.h21
-rw-r--r--usr.bin/make/lst.lib/lstDestroy.c2
-rw-r--r--usr.bin/make/lst.lib/lstDupl.c2
-rw-r--r--usr.bin/make/lst.lib/lstFind.c2
-rw-r--r--usr.bin/make/lst.lib/lstFindFrom.c2
-rw-r--r--usr.bin/make/lst.lib/lstForEach.c2
-rw-r--r--usr.bin/make/lst.lib/lstForEachFrom.c2
-rw-r--r--usr.bin/make/main.c2
-rw-r--r--usr.bin/make/parse.c2
10 files changed, 22 insertions, 17 deletions
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c
index 6502401..16c8ebf 100644
--- a/usr.bin/make/for.c
+++ b/usr.bin/make/for.c
@@ -293,6 +293,6 @@ For_Run(int lineno)
Lst_ForEach(arg.lst, ForExec, (void *) &arg);
free(arg.var);
- Lst_Destroy(arg.lst, (void (*)(void *)) free);
+ Lst_Destroy(arg.lst, free);
Buf_Destroy(arg.buf, TRUE);
}
diff --git a/usr.bin/make/lst.h b/usr.bin/make/lst.h
index 1842061..1accf25 100644
--- a/usr.bin/make/lst.h
+++ b/usr.bin/make/lst.h
@@ -93,13 +93,18 @@ struct Lst {
};
typedef struct Lst *Lst;
+typedef int CompareProc(void *, void *);
+typedef int DoProc(void *, void *);
+typedef void *DuplicateProc(void *);
+typedef void FreeProc(void *);
+
/*
* NOFREE can be used as the freeProc to Lst_Destroy when the elements are
* not to be freed.
* NOCOPY performs similarly when given as the copyProc to Lst_Duplicate.
*/
-#define NOFREE ((void (*)(void *)) 0)
-#define NOCOPY ((void * (*)(void *)) 0)
+#define NOFREE ((FreeProc *)NULL)
+#define NOCOPY ((DuplicateProc *)NULL)
#define LST_CONCNEW 0 /* create new LstNode's when using Lst_Concat */
#define LST_CONCLINK 1 /* relink LstNode's when using Lst_Concat */
@@ -110,9 +115,9 @@ typedef struct Lst *Lst;
/* Create a new list */
Lst Lst_Init(Boolean);
/* Duplicate an existing list */
-Lst Lst_Duplicate(Lst, void * (*)(void *));
+Lst Lst_Duplicate(Lst, DuplicateProc *);
/* Destroy an old one */
-void Lst_Destroy(Lst, void (*)(void *));
+void Lst_Destroy(Lst, FreeProc *);
/*
* Functions to modify a list
@@ -148,22 +153,22 @@ void * Lst_Datum(LstNode);
* Functions for entire lists
*/
/* Find an element in a list */
-LstNode Lst_Find(Lst, void *, int (*)(void *, void *));
+LstNode Lst_Find(Lst, void *, CompareProc *);
/* Find an element starting from somewhere */
-LstNode Lst_FindFrom(Lst, LstNode, void *, int (*cProc)(void *, void *));
+LstNode Lst_FindFrom(Lst, LstNode, void *, CompareProc *);
/*
* See if the given datum is on the list. Returns the LstNode containing
* the datum
*/
LstNode Lst_Member(Lst, void *);
/* Apply a function to all elements of a lst */
-void Lst_ForEach(Lst, int (*)(void *, void *), void *);
+void Lst_ForEach(Lst, DoProc *, void *);
/*
* Apply a function to all elements of a lst starting from a certain point.
* If the list is circular, the application will wrap around to the
* beginning of the list again.
*/
-void Lst_ForEachFrom(Lst, LstNode, int (*)(void *, void *), void *);
+void Lst_ForEachFrom(Lst, LstNode, DoProc *, void *);
/*
* these functions are for dealing with a list as a table, of sorts.
* An idea of the "current element" is kept and used by all the functions
diff --git a/usr.bin/make/lst.lib/lstDestroy.c b/usr.bin/make/lst.lib/lstDestroy.c
index 8942ddf..2a43c1d 100644
--- a/usr.bin/make/lst.lib/lstDestroy.c
+++ b/usr.bin/make/lst.lib/lstDestroy.c
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
*-----------------------------------------------------------------------
*/
void
-Lst_Destroy(Lst list, void (*freeProc)(void *))
+Lst_Destroy(Lst list, FreeProc *freeProc)
{
LstNode ln;
LstNode tln = NULL;
diff --git a/usr.bin/make/lst.lib/lstDupl.c b/usr.bin/make/lst.lib/lstDupl.c
index 4c1842d..58f3f56 100644
--- a/usr.bin/make/lst.lib/lstDupl.c
+++ b/usr.bin/make/lst.lib/lstDupl.c
@@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
*-----------------------------------------------------------------------
*/
Lst
-Lst_Duplicate(Lst list, void *(*copyProc)(void *))
+Lst_Duplicate(Lst list, DuplicateProc *copyProc)
{
Lst nl;
LstNode ln;
diff --git a/usr.bin/make/lst.lib/lstFind.c b/usr.bin/make/lst.lib/lstFind.c
index d27907c..f0c1141 100644
--- a/usr.bin/make/lst.lib/lstFind.c
+++ b/usr.bin/make/lst.lib/lstFind.c
@@ -64,7 +64,7 @@ __FBSDID("$FreeBSD$");
*-----------------------------------------------------------------------
*/
LstNode
-Lst_Find(Lst l, void *d, int (*cProc)(void *, void *))
+Lst_Find(Lst l, void *d, CompareProc *cProc)
{
return (Lst_FindFrom (l, Lst_First(l), d, cProc));
diff --git a/usr.bin/make/lst.lib/lstFindFrom.c b/usr.bin/make/lst.lib/lstFindFrom.c
index 25b8c13..557048b 100644
--- a/usr.bin/make/lst.lib/lstFindFrom.c
+++ b/usr.bin/make/lst.lib/lstFindFrom.c
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
*-----------------------------------------------------------------------
*/
LstNode
-Lst_FindFrom(Lst l, LstNode ln, void *d, int (*cProc)(void *, void *))
+Lst_FindFrom(Lst l, LstNode ln, void *d, CompareProc *cProc)
{
LstNode tln;
Boolean found = FALSE;
diff --git a/usr.bin/make/lst.lib/lstForEach.c b/usr.bin/make/lst.lib/lstForEach.c
index ee3e041..0d73cd0 100644
--- a/usr.bin/make/lst.lib/lstForEach.c
+++ b/usr.bin/make/lst.lib/lstForEach.c
@@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$");
*-----------------------------------------------------------------------
*/
void
-Lst_ForEach(Lst l, int (*proc)(void *, void *), void *d)
+Lst_ForEach(Lst l, DoProc *proc, void *d)
{
Lst_ForEachFrom(l, Lst_First(l), proc, d);
diff --git a/usr.bin/make/lst.lib/lstForEachFrom.c b/usr.bin/make/lst.lib/lstForEachFrom.c
index 26c5858..69742d0 100644
--- a/usr.bin/make/lst.lib/lstForEachFrom.c
+++ b/usr.bin/make/lst.lib/lstForEachFrom.c
@@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$");
*-----------------------------------------------------------------------
*/
void
-Lst_ForEachFrom(Lst list, LstNode ln, int (*proc)(void *, void *), void *d)
+Lst_ForEachFrom(Lst list, LstNode ln, DoProc *proc, void *d)
{
LstNode next;
Boolean done;
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 32e7fea..19f00b6 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -874,7 +874,7 @@ main(int argc, char **argv)
Lst_Destroy(variables, NOFREE);
Lst_Destroy(makefiles, NOFREE);
- Lst_Destroy(create, (void (*)(void *)) free);
+ Lst_Destroy(create, free);
/* print the graph now it's been processed if the user requested it */
if (DEBUG(GRAPH2))
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 52a1bc3..9803e7d 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -2536,7 +2536,7 @@ Parse_Init (void)
void
Parse_End (void)
{
- Lst_Destroy(targCmds, (void (*)(void *)) free);
+ Lst_Destroy(targCmds, free);
if (targets)
Lst_Destroy(targets, NOFREE);
Lst_Destroy(sysIncPath, Dir_Destroy);
OpenPOWER on IntegriCloud