diff options
author | Richard Braun <rbraun@sceen.net> | 2018-02-23 09:53:00 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-02-23 09:56:13 +0100 |
commit | fec9bb4f8f17f3e45a5a869701c65f2f7f0fa299 (patch) | |
tree | b17efde7e14c244680915516cf4c994950d44347 /src | |
parent | 5df0aba1129b292f41f83ac679fd46a52bc9af3e (diff) |
rdxtree: use bool instead of int wwhere applicable
Diffstat (limited to 'src')
-rw-r--r-- | src/rdxtree.c | 14 | ||||
-rw-r--r-- | src/rdxtree.h | 7 | ||||
-rw-r--r-- | src/rdxtree_i.h | 6 |
3 files changed, 15 insertions, 12 deletions
diff --git a/src/rdxtree.c b/src/rdxtree.c index d5fc7ee..38ee7cb 100644 --- a/src/rdxtree.c +++ b/src/rdxtree.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 Richard Braun. + * Copyright (c) 2011-2018 Richard Braun. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -120,7 +120,7 @@ rdxtree_entry_addr(void *entry) return (void *)((uintptr_t)entry & RDXTREE_ENTRY_ADDR_MASK); } -static inline int +static inline bool rdxtree_entry_is_node(const void *entry) { return ((uintptr_t)entry & 1) != 0; @@ -191,13 +191,13 @@ rdxtree_node_unlink(struct rdxtree_node *node) node->parent = NULL; } -static inline int +static inline bool rdxtree_node_full(struct rdxtree_node *node) { return (node->nr_entries == ARRAY_SIZE(node->entries)); } -static inline int +static inline bool rdxtree_node_empty(struct rdxtree_node *node) { return (node->nr_entries == 0); @@ -265,13 +265,13 @@ rdxtree_node_bm_clear(struct rdxtree_node *node, unsigned short index) node->alloc_bm &= ~((rdxtree_bm_t)1 << index); } -static inline int +static inline bool rdxtree_node_bm_is_set(struct rdxtree_node *node, unsigned short index) { return (node->alloc_bm & ((rdxtree_bm_t)1 << index)); } -static inline int +static inline bool rdxtree_node_bm_empty(struct rdxtree_node *node) { return (node->alloc_bm == RDXTREE_BM_EMPTY); @@ -660,7 +660,7 @@ rdxtree_remove(struct rdxtree *tree, rdxtree_key_t key) void * rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key, - int get_slot) + bool get_slot) { struct rdxtree_node *node, *prev; unsigned short height, shift, index; diff --git a/src/rdxtree.h b/src/rdxtree.h index 018bb70..a2a66cb 100644 --- a/src/rdxtree.h +++ b/src/rdxtree.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 Richard Braun. + * Copyright (c) 2011-2018 Richard Braun. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -32,6 +32,7 @@ #ifndef RDXTREE_H #define RDXTREE_H +#include <stdbool.h> #include <stddef.h> #include <stdint.h> @@ -158,7 +159,7 @@ void * rdxtree_remove(struct rdxtree *tree, rdxtree_key_t key); static inline void * rdxtree_lookup(const struct rdxtree *tree, rdxtree_key_t key) { - return rdxtree_lookup_common(tree, key, 0); + return rdxtree_lookup_common(tree, key, false); } /* @@ -175,7 +176,7 @@ rdxtree_lookup(const struct rdxtree *tree, rdxtree_key_t key) static inline void ** rdxtree_lookup_slot(const struct rdxtree *tree, rdxtree_key_t key) { - return rdxtree_lookup_common(tree, key, 1); + return rdxtree_lookup_common(tree, key, true); } static inline void * diff --git a/src/rdxtree_i.h b/src/rdxtree_i.h index fabf17f..70a5f98 100644 --- a/src/rdxtree_i.h +++ b/src/rdxtree_i.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 Richard Braun. + * Copyright (c) 2011-2018 Richard Braun. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,6 +26,8 @@ #ifndef RDXTREE_I_H #define RDXTREE_I_H +#include <stdbool.h> + /* * Radix tree. */ @@ -64,7 +66,7 @@ int rdxtree_insert_alloc_common(struct rdxtree *tree, void *ptr, rdxtree_key_t *keyp, void ***slotp); void * rdxtree_lookup_common(const struct rdxtree *tree, rdxtree_key_t key, - int get_slot); + bool get_slot); void * rdxtree_walk(struct rdxtree *tree, struct rdxtree_iter *iter); |