libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] tsearch updates from NetBSD source


From: Evgeny Grin
Subject: Re: [libmicrohttpd] tsearch updates from NetBSD source
Date: Wed, 27 Nov 2019 16:15:14 +0300

This could cause a problem on platforms where size of unsigned long is smaller than size of pointer. Windows x64 is obvious example.
 
-- 
Best Wishes,
Evgeny Grin
 
 
 
27.11.2019, 14:47, "ng0" <address@hidden>:

Hi,

is this okay for merge? I took it from our (NetBSD) tree,
compared to what libmicrohttpd contains.

diff --git a/src/lib/tsearch.c b/src/lib/tsearch.c
index 78f37608..2d374cad 100644
--- a/src/lib/tsearch.c
+++ b/src/lib/tsearch.c
@@ -12,6 +12,9 @@
 #include "tsearch.h"
 #include <stdlib.h>

+#ifndef __UNCONST
+#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
+#endif

 typedef struct node
 {
@@ -21,7 +24,7 @@ typedef struct node
 } node_t;


-/* $NetBSD: tsearch.c,v 1.5 2005/11/29 03:12:00 christos Exp $ */
+/* $NetBSD: tsearch.c,v 1.7 2012/06/25 22:32:45 abs Exp $ */
 /* find or insert datum into search tree */
 void *
 tsearch (const void *vkey, /* key to be located */
@@ -47,10 +50,10 @@ tsearch (const void *vkey, /* key to be located */
   }

   q = malloc (sizeof(node_t)); /* T5: key not found */
- if (q)
+ if (q != 0)
   { /* make new node */
     *rootp = q; /* link new node to old */
- q->key = vkey; /* initialize new node */
+ q->key = __UNCONST(vkey); /* initialize new node */
     q->llink = q->rlink = NULL;
   }
   return q;
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]