rbtree
diff src/rbtree.c @ 10:b45febfd2922
fixed all the conversion warnings
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 16 Apr 2012 00:30:59 +0300 |
parents | 2c0baa1fd419 |
children | 5b955b3a4675 |
line diff
1.1 --- a/src/rbtree.c Mon Apr 16 00:26:38 2012 +0300 1.2 +++ b/src/rbtree.c Mon Apr 16 00:30:59 2012 +0300 1.3 @@ -1,10 +1,11 @@ 1.4 #include <stdio.h> 1.5 #include <stdlib.h> 1.6 +#include <stdint.h> 1.7 #include <string.h> 1.8 #include "rbtree.h" 1.9 1.10 -#define INT2PTR(x) ((void*)(x)) 1.11 -#define PTR2INT(x) ((int)(x)) 1.12 +#define INT2PTR(x) ((void*)(intptr_t)(x)) 1.13 +#define PTR2INT(x) ((int)(intptr_t)(x)) 1.14 1.15 struct rbtree { 1.16 struct rbnode *root; 1.17 @@ -19,8 +20,8 @@ 1.18 struct rbnode *rstack, *iter; 1.19 }; 1.20 1.21 -static int cmpaddr(void *ap, void *bp); 1.22 -static int cmpint(void *ap, void *bp); 1.23 +static int cmpaddr(const void *ap, const void *bp); 1.24 +static int cmpint(const void *ap, const void *bp); 1.25 1.26 static int count_nodes(struct rbnode *node); 1.27 static void del_tree(struct rbnode *node, void (*delfunc)(struct rbnode*, void*), void *cls); 1.28 @@ -221,12 +222,12 @@ 1.29 return node ? node->data : 0; 1.30 } 1.31 1.32 -static int cmpaddr(void *ap, void *bp) 1.33 +static int cmpaddr(const void *ap, const void *bp) 1.34 { 1.35 return ap < bp ? -1 : (ap > bp ? 1 : 0); 1.36 } 1.37 1.38 -static int cmpint(void *ap, void *bp) 1.39 +static int cmpint(const void *ap, const void *bp) 1.40 { 1.41 return PTR2INT(ap) - PTR2INT(bp); 1.42 }