]> wimlib.net Git - wimlib/commitdiff
rbtree: Use uintptr_t instead of unsigned long
authorEric Biggers <ebiggers3@gmail.com>
Sun, 17 Mar 2013 23:47:04 +0000 (18:47 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 17 Mar 2013 23:47:04 +0000 (18:47 -0500)
src/rbtree.c
src/rbtree.h

index 71a2c533e1fbbbdaec30e99bf67225402f5ab8c3..6e122da4b651e2f7138e44d2676a95ff121549a0 100644 (file)
@@ -63,13 +63,13 @@ struct rb_augment_callbacks {
 
 static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
 {
-       rb->__rb_parent_color = rb_color(rb) | (unsigned long)p;
+       rb->__rb_parent_color = rb_color(rb) | (uintptr_t)p;
 }
 
 static inline void rb_set_parent_color(struct rb_node *rb,
                                       struct rb_node *p, int color)
 {
-       rb->__rb_parent_color = (unsigned long)p | color;
+       rb->__rb_parent_color = (uintptr_t)p | color;
 }
 
 static inline void rb_set_black(struct rb_node *rb)
@@ -278,7 +278,7 @@ rb_erase_augmented(struct rb_node *node, struct rb_root *root,
 {
        struct rb_node *child = node->rb_right, *tmp = node->rb_left;
        struct rb_node *parent, *rebalance;
-       unsigned long pc;
+       uintptr_t pc;
 
        if (!tmp) {
                /*
@@ -358,7 +358,7 @@ rb_erase_augmented(struct rb_node *node, struct rb_root *root,
                        rb_set_parent_color(child2, parent, RB_BLACK);
                        rebalance = NULL;
                } else {
-                       unsigned long pc2 = successor->__rb_parent_color;
+                       uintptr_t pc2 = successor->__rb_parent_color;
                        successor->__rb_parent_color = pc;
                        rebalance = __rb_is_black(pc2) ? parent : NULL;
                }
index 583230e0e787bfa8688b6bf1fe2a44bc56612327..c9321a68c35a2fd0f88d601fa19624292f80c7fa 100644 (file)
 #define        _LINUX_RBTREE_H
 
 #include "util.h"
+#include <stdint.h>
 
 struct rb_node {
-       unsigned long  __rb_parent_color;
+       uintptr_t  __rb_parent_color;
        struct rb_node *rb_right;
        struct rb_node *rb_left;
 };
@@ -51,7 +52,7 @@ extern void rb_erase(struct rb_node *, struct rb_root *);
 static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
                                struct rb_node ** rb_link)
 {
-       node->__rb_parent_color = (unsigned long)parent;
+       node->__rb_parent_color = (uintptr_t)parent;
        node->rb_left = node->rb_right = NULL;
 
        *rb_link = node;