Module Name:    src
Committed By:   rillig
Date:           Sun Aug 23 16:43:35 UTC 2020

Modified Files:
        src/usr.bin/make: lst.c lst.h meta.c

Log Message:
make(1): define aliases for function types in list processing

This makes the prototypes of the functions clearer.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/make/lst.c src/usr.bin/make/lst.h
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/make/meta.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.39 src/usr.bin/make/lst.c:1.40
--- src/usr.bin/make/lst.c:1.39	Sun Aug 23 16:18:12 2020
+++ src/usr.bin/make/lst.c	Sun Aug 23 16:43:34 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.39 2020/08/23 16:18:12 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.40 2020/08/23 16:43:34 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.39 2020/08/23 16:18:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.40 2020/08/23 16:43:34 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.39 2020/08/23 16:18:12 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.40 2020/08/23 16:43:34 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -125,7 +125,7 @@ Lst_Init(void)
  * If copyProc is given, that function is used to create the new datum from the
  * old datum, usually by creating a copy of it. */
 Lst
-Lst_CopyS(Lst list, DuplicateProc *copyProc)
+Lst_CopyS(Lst list, LstCopyProc copyProc)
 {
     Lst newList;
     LstNode node;
@@ -145,7 +145,7 @@ Lst_CopyS(Lst list, DuplicateProc *copyP
 /* Destroy a list and free all its resources. If the freeProc is given, it is
  * called with the datum from each node in turn before the node is freed. */
 void
-Lst_Destroy(Lst list, FreeProc *freeProc)
+Lst_Destroy(Lst list, LstFreeProc freeProc)
 {
     LstNode node;
     LstNode next = NULL;
Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.39 src/usr.bin/make/lst.h:1.40
--- src/usr.bin/make/lst.h:1.39	Sun Aug 23 10:53:27 2020
+++ src/usr.bin/make/lst.h	Sun Aug 23 16:43:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.39 2020/08/23 10:53:27 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.40 2020/08/23 16:43:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -92,8 +92,10 @@
 typedef	struct List	*Lst;
 typedef	struct ListNode	*LstNode;
 
-typedef void		*DuplicateProc(void *);
-typedef void		FreeProc(void *);
+typedef void *LstCopyProc(void *);
+typedef void LstFreeProc(void *);
+typedef int LstFindProc(const void *, const void *);
+typedef int LstActionProc(void *, void *);
 
 /*
  * Creation/destruction functions
@@ -101,9 +103,9 @@ typedef void		FreeProc(void *);
 /* Create a new list */
 Lst		Lst_Init(void);
 /* Duplicate an existing list */
-Lst		Lst_CopyS(Lst, DuplicateProc *);
+Lst		Lst_CopyS(Lst, LstCopyProc);
 /* Destroy an old one */
-void		Lst_Destroy(Lst, FreeProc *);
+void		Lst_Destroy(Lst, LstFreeProc);
 /* True if list is empty */
 Boolean		Lst_IsEmpty(Lst);
 
@@ -144,20 +146,18 @@ void		*Lst_DatumS(LstNode);
  * Functions for entire lists
  */
 /* Find an element in a list */
-LstNode		Lst_Find(Lst, const void *, int (*)(const void *, const void *));
+LstNode		Lst_Find(Lst, const void *, LstFindProc);
 /* Find an element starting from somewhere */
-LstNode		Lst_FindFrom(Lst, LstNode, const void *,
-			     int (*cmp)(const void *, const void *));
+LstNode		Lst_FindFrom(Lst, LstNode, const void *, LstFindProc);
 /*
  * See if the given datum is on the list. Returns the LstNode containing
  * the datum
  */
 LstNode		Lst_MemberS(Lst, void *);
 /* Apply a function to all elements of a lst */
-int		Lst_ForEach(Lst, int (*)(void *, void *), void *);
+int		Lst_ForEach(Lst, LstActionProc, void *);
 /* Apply a function to all elements of a lst starting from a certain point. */
-int		Lst_ForEachFrom(Lst, LstNode, int (*)(void *, void *),
-				void *);
+int		Lst_ForEachFrom(Lst, LstNode, LstActionProc, 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: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.97 src/usr.bin/make/meta.c:1.98
--- src/usr.bin/make/meta.c:1.97	Sat Aug 22 17:34:25 2020
+++ src/usr.bin/make/meta.c	Sun Aug 23 16:43:34 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.97 2020/08/22 17:34:25 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.98 2020/08/23 16:43:34 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -1623,7 +1623,7 @@ meta_oodate(GNode *gn, Boolean oodate)
 	}
     }
 
-    Lst_Destroy(missingFiles, (FreeProc *)free);
+    Lst_Destroy(missingFiles, free);
 
     if (oodate && needOODATE) {
 	/*

Reply via email to