DragonFly BSD
DragonFly submit List (threaded) for 2004-12
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

usr.bin/make typedef function pointer types to clarify paramters.


From: Max Okumoto <okumoto@xxxxxxxx>
Date: Wed, 01 Dec 2004 16:00:24 -0800

Use typedefs for the types of the functions that are passed as arguments
to the list functions for better readability.

Max
---------------------
PatchSet 383
Date: 2004/11/29 12:17:12
Author: harti
Log:
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@xxxxxxxx>

Members: 
	for.c:1.21->1.22 
	lst.h:1.16->1.17 
	main.c:1.100->1.101 
	parse.c:1.58->1.59 
	lst.lib/lstDestroy.c:1.14->1.15 
	lst.lib/lstDupl.c:1.14->1.15 
	lst.lib/lstFind.c:1.13->1.14 
	lst.lib/lstFindFrom.c:1.14->1.15 
	lst.lib/lstForEach.c:1.12->1.13 
	lst.lib/lstForEachFrom.c:1.14->1.15 

Index: for.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/for.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- for.c	10 Mar 2004 21:51:06 -0000	1.21
+++ for.c	29 Nov 2004 12:17:12 -0000	1.22
@@ -293,6 +293,6 @@
     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);
 }
Index: lst.h
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/lst.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- lst.h	29 Nov 2004 08:38:16 -0000	1.16
+++ lst.h	29 Nov 2004 12:17:12 -0000	1.17
@@ -93,13 +93,18 @@
 };
 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 @@
 /* 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 @@
  * 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
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- main.c	25 Nov 2004 12:50:16 -0000	1.100
+++ main.c	29 Nov 2004 12:17:12 -0000	1.101
@@ -874,7 +874,7 @@
 
 	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))
Index: parse.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- parse.c	17 Nov 2004 11:32:46 -0000	1.58
+++ parse.c	29 Nov 2004 12:17:12 -0000	1.59
@@ -2536,7 +2536,7 @@
 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);
Index: lst.lib/lstDestroy.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/lst.lib/lstDestroy.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- lst.lib/lstDestroy.c	29 Nov 2004 08:38:16 -0000	1.14
+++ lst.lib/lstDestroy.c	29 Nov 2004 12:17:13 -0000	1.15
@@ -65,7 +65,7 @@
  *-----------------------------------------------------------------------
  */
 void
-Lst_Destroy(Lst list, void (*freeProc)(void *))
+Lst_Destroy(Lst list, FreeProc *freeProc)
 {
     LstNode	ln;
     LstNode	tln = NULL;
Index: lst.lib/lstDupl.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/lst.lib/lstDupl.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- lst.lib/lstDupl.c	29 Nov 2004 08:38:16 -0000	1.14
+++ lst.lib/lstDupl.c	29 Nov 2004 12:17:13 -0000	1.15
@@ -68,7 +68,7 @@
  *-----------------------------------------------------------------------
  */
 Lst
-Lst_Duplicate(Lst list, void *(*copyProc)(void *))
+Lst_Duplicate(Lst list, DuplicateProc *copyProc)
 {
     Lst 	nl;
     LstNode  	ln;
Index: lst.lib/lstFind.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/lst.lib/lstFind.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- lst.lib/lstFind.c	29 Nov 2004 08:38:16 -0000	1.13
+++ lst.lib/lstFind.c	29 Nov 2004 12:17:13 -0000	1.14
@@ -64,7 +64,7 @@
  *-----------------------------------------------------------------------
  */
 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));
Index: lst.lib/lstFindFrom.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/lst.lib/lstFindFrom.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- lst.lib/lstFindFrom.c	29 Nov 2004 08:38:16 -0000	1.14
+++ lst.lib/lstFindFrom.c	29 Nov 2004 12:17:13 -0000	1.15
@@ -65,7 +65,7 @@
  *-----------------------------------------------------------------------
  */
 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;
Index: lst.lib/lstForEach.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/lst.lib/lstForEach.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- lst.lib/lstForEach.c	29 Nov 2004 08:38:16 -0000	1.12
+++ lst.lib/lstForEach.c	29 Nov 2004 12:17:13 -0000	1.13
@@ -65,7 +65,7 @@
  *-----------------------------------------------------------------------
  */
 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);
Index: lst.lib/lstForEachFrom.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/lst.lib/lstForEachFrom.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- lst.lib/lstForEachFrom.c	29 Nov 2004 08:38:16 -0000	1.14
+++ lst.lib/lstForEachFrom.c	29 Nov 2004 12:17:13 -0000	1.15
@@ -66,7 +66,7 @@
  *-----------------------------------------------------------------------
  */
 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;


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]