diff options
Diffstat (limited to 'zix')
-rw-r--r-- | zix/bitset.c | 2 | ||||
-rw-r--r-- | zix/btree.c | 10 | ||||
-rw-r--r-- | zix/sorted_array.c | 14 | ||||
-rw-r--r-- | zix/trie.c | 2 | ||||
-rw-r--r-- | zix/trie_util.h | 4 |
5 files changed, 16 insertions, 16 deletions
diff --git a/zix/bitset.c b/zix/bitset.c index e5f8348..2f551b2 100644 --- a/zix/bitset.c +++ b/zix/bitset.c @@ -103,7 +103,7 @@ zix_bitset_count_up_to_if(const ZixBitset* b, const ZixBitsetTally* t, size_t i) if (extra) { const ZixBitset mask = ~(~(ZixBitset)0 << extra); - count += __builtin_popcountl(b[full_elems] & mask); + count += (size_t)__builtin_popcountl(b[full_elems] & mask); } return count; diff --git a/zix/btree.c b/zix/btree.c index de5d777..9990b18 100644 --- a/zix/btree.c +++ b/zix/btree.c @@ -170,7 +170,7 @@ zix_btree_max_vals(const ZixBTreeNode* const node) ZIX_PRIVATE uint16_t zix_btree_min_vals(const ZixBTreeNode* const node) { - return ((zix_btree_max_vals(node) + 1U) / 2U) - 1U; + return (uint16_t)(((zix_btree_max_vals(node) + 1U) / 2U) - 1U); } /** Shift pointers in `array` of length `n` right starting at `i`. */ @@ -212,7 +212,7 @@ zix_btree_split_child(ZixBTreeNode* const n, // LHS and RHS get roughly half, less the middle value which moves up lhs->n_vals = max_n_vals / 2U; - rhs->n_vals = max_n_vals - lhs->n_vals - 1U; + rhs->n_vals = (uint16_t)(max_n_vals - lhs->n_vals - 1); // Copy large half of values from LHS to new RHS node memcpy(rhs->vals, @@ -223,7 +223,7 @@ zix_btree_split_child(ZixBTreeNode* const n, if (!lhs->is_leaf) { memcpy(rhs->children, lhs->children + lhs->n_vals + 1, - (rhs->n_vals + 1) * sizeof(ZixBTreeNode*)); + (rhs->n_vals + 1U) * sizeof(ZixBTreeNode*)); } // Move middle value up to parent @@ -416,9 +416,9 @@ zix_btree_merge(ZixBTree* const t, ZixBTreeNode* const n, const unsigned i) if (!lhs->is_leaf) { memcpy(lhs->children + lhs->n_vals, rhs->children, - (rhs->n_vals + 1) * sizeof(void*)); + (rhs->n_vals + 1U) * sizeof(void*)); } - lhs->n_vals += rhs->n_vals; + lhs->n_vals = (uint16_t)(lhs->n_vals + rhs->n_vals); if (--n->n_vals == 0) { // Root is now empty, replace it with its only child diff --git a/zix/sorted_array.c b/zix/sorted_array.c index 8929d35..b2096b2 100644 --- a/zix/sorted_array.c +++ b/zix/sorted_array.c @@ -97,7 +97,7 @@ zix_sorted_array_insert(ZixSortedArray* a, zix_sorted_array_find(a, e, ai); assert(*ai); - const size_t i = ((char*)*ai - (char*)a->array) / a->elem_size; + const size_t i = (size_t)((char*)*ai - (char*)a->array) / a->elem_size; a->array = realloc(a->array, ++a->num_elems * a->elem_size); memmove((char*)a->array + ((i + 1) * a->elem_size), @@ -116,7 +116,7 @@ ZIX_API ZixStatus zix_sorted_array_remove(ZixSortedArray* a, ZixSortedArrayIter ai) { - const size_t i = ((char*)ai - (char*)a->array) / a->elem_size; + const size_t i = (size_t)((char*)ai - (char*)a->array) / a->elem_size; memmove((char*)a->array + (i * a->elem_size), (char*)a->array + ((i + 1) * a->elem_size), (a->num_elems - i - 1) * a->elem_size); @@ -148,12 +148,12 @@ zix_sorted_array_find(const ZixSortedArray* a, const void* e, ZixSortedArrayIter* ai) { - intptr_t lower = 0; - intptr_t upper = a->num_elems - 1; + uintptr_t lower = 0; + uintptr_t upper = (uintptr_t)a->num_elems - 1; while (upper >= lower) { - const intptr_t i = lower + ((upper - lower) / 2); - void* const elem_i = zix_sorted_array_index_unchecked(a, i); - const int cmp = a->cmp(elem_i, e, a->cmp_data); + const uintptr_t i = lower + ((upper - lower) / 2); + void* const elem_i = zix_sorted_array_index_unchecked(a, i); + const int cmp = a->cmp(elem_i, e, a->cmp_data); if (cmp == 0) { *ai = elem_i; @@ -101,7 +101,7 @@ zix_trie_node_size(n_edges_t num_children) } ZIX_PRIVATE ZixTrieNode* -realloc_node(ZixTrieNode* n, int num_children) +realloc_node(ZixTrieNode* n, n_edges_t num_children) { return (ZixTrieNode*)realloc(n, zix_trie_node_size(num_children)); } diff --git a/zix/trie_util.h b/zix/trie_util.h index e21d9d6..ed429b3 100644 --- a/zix/trie_util.h +++ b/zix/trie_util.h @@ -42,7 +42,7 @@ zix_trie_find_key(const uint8_t* const keys, const size_t n, const uint8_t k) #else /** Return the index of the first element in `keys` >= `k`, or `n`. */ -ZIX_PRIVATE size_t +static inline size_t zix_trie_find_key(const uint8_t* const keys, const size_t n, const uint8_t k) { size_t first = 0; @@ -111,7 +111,7 @@ zix_trie_change_index_sse(const uint8_t* a, const uint8_t* b, const size_t len) #endif -ZIX_PRIVATE size_t +static inline size_t zix_trie_change_index(const uint8_t* a, const uint8_t* b, const size_t len) { #ifdef __SSE4_2__ |