[vlc-devel] [PATCH 2/2] compat: tfind: Don't use K&R prototypes

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Dec 3 20:19:19 CET 2020


Some compilers are now refusing that syntax
---
 compat/tfind.c | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/compat/tfind.c b/compat/tfind.c
index 743fa67513..8457562419 100644
--- a/compat/tfind.c
+++ b/compat/tfind.c
@@ -31,11 +31,7 @@ typedef struct node {
  */
 
 /* delete node with given key */
-void *
-tdelete(vkey, vrootp, compar)
-	const void *vkey;	/* key to be deleted */
-	void      **vrootp;	/* address of the root of tree */
-	int       (*compar) (const void *, const void *);
+void* tdelete(const void* vkey, void** vrootp, int (*compar)(const void*, const void*))
 {
 	node_t **rootp = (node_t **)vrootp;
 	node_t *p, *q, *r;
@@ -104,9 +100,7 @@ tdestroy_recurse(node_t* root, void (*free_action)(void *))
 }
 
 void
-tdestroy(vrootp, freefct)
-       void *vrootp;
-       void (*freefct)(void *);
+tdestroy(void *vrootp, void (*freefct)(void*))
 {
   node_t *root = (node_t *) vrootp;
 
@@ -130,10 +124,7 @@ tdestroy(vrootp, freefct)
 
 /* find a node, or return 0 */
 void *
-tfind(vkey, vrootp, compar)
-	const void *vkey;		/* key to be found */
-	void * const *vrootp;		/* address of the tree root */
-	int (*compar) (const void *, const void *);
+tfind(const void* vkey, void* const *vrootp, int (*compar) (const void *, const void *))
 {
 	node_t * const *rootp = (node_t * const*)vrootp;
 
@@ -171,10 +162,7 @@ tfind(vkey, vrootp, compar)
 
 /* 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;
@@ -221,10 +209,7 @@ tsearch(vkey, vrootp, compar)
 
 /* Walk the nodes of a tree */
 static void
-twalk_recurse(root, action, level)
-	const node_t *root;	/* Root of the tree to be walked */
-	void (*action) (const void *, VISIT, int);
-	int level;
+twalk_recurse(const node_t* root, void (*action)(const void*, VISIT, int), int level)
 {
 	assert(root != NULL);
 	assert(action != NULL);
@@ -243,10 +228,8 @@ twalk_recurse(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);
+void 
+twalk(const void* vroot, void (*action)(const void*, VISIT, int))
 {
 	if (vroot != NULL && action != NULL)
 		twalk_recurse(vroot, action, 0);
-- 
2.29.2



More information about the vlc-devel mailing list