Commit f5d7ee1a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

rbtree.h: Store compare function instead of wine_rb_functions in wine_rb_tree.

parent 002af352
...@@ -44,7 +44,7 @@ struct wine_rb_functions ...@@ -44,7 +44,7 @@ struct wine_rb_functions
struct wine_rb_tree struct wine_rb_tree
{ {
const struct wine_rb_functions *functions; int (*compare)(const void *key, const struct wine_rb_entry *entry);
struct wine_rb_entry *root; struct wine_rb_entry *root;
}; };
...@@ -131,7 +131,7 @@ static inline void wine_rb_postorder(struct wine_rb_tree *tree, wine_rb_traverse ...@@ -131,7 +131,7 @@ static inline void wine_rb_postorder(struct wine_rb_tree *tree, wine_rb_traverse
static inline int wine_rb_init(struct wine_rb_tree *tree, const struct wine_rb_functions *functions) static inline int wine_rb_init(struct wine_rb_tree *tree, const struct wine_rb_functions *functions)
{ {
tree->functions = functions; tree->compare = functions->compare;
tree->root = NULL; tree->root = NULL;
return 0; return 0;
...@@ -159,7 +159,7 @@ static inline struct wine_rb_entry *wine_rb_get(const struct wine_rb_tree *tree, ...@@ -159,7 +159,7 @@ static inline struct wine_rb_entry *wine_rb_get(const struct wine_rb_tree *tree,
struct wine_rb_entry *entry = tree->root; struct wine_rb_entry *entry = tree->root;
while (entry) while (entry)
{ {
int c = tree->functions->compare(key, entry); int c = tree->compare(key, entry);
if (!c) return entry; if (!c) return entry;
entry = c < 0 ? entry->left : entry->right; entry = c < 0 ? entry->left : entry->right;
} }
...@@ -175,7 +175,7 @@ static inline int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct ...@@ -175,7 +175,7 @@ static inline int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct
int c; int c;
parent = *iter; parent = *iter;
c = tree->functions->compare(key, parent); c = tree->compare(key, parent);
if (!c) return -1; if (!c) return -1;
else if (c < 0) iter = &parent->left; else if (c < 0) iter = &parent->left;
else iter = &parent->right; else iter = &parent->right;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment