summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cmap.h
diff options
context:
space:
mode:
authorCamel Coder <[email protected]>2022-02-12 18:42:34 +0000
committerGitHub <[email protected]>2022-02-12 18:42:34 +0000
commit8d4a2f591986e929a4d1a446dbed4494c0a00866 (patch)
tree101ef57b91e5fda55f94286a3ecda2c300eaa5b8 /include/stc/cmap.h
parent00cc6351fd4a0cdf216eba3cc4918aa3c7aa0704 (diff)
downloadSTC-modified-8d4a2f591986e929a4d1a446dbed4494c0a00866.tar.gz
STC-modified-8d4a2f591986e929a4d1a446dbed4494c0a00866.zip
Fixed cmap.h for `sizeof(uint_fast8_t) != 1`
Adding `#define uint_fast8_t uint32_t` to examples/hashmap.c breaks the code. `_hx` of type `uint8_t` is compared to the non-truncated `b.hx` of type `uint_fast8_t`, this comparison fails when `sizeof(uint_fast8_t) != 1`.
Diffstat (limited to 'include/stc/cmap.h')
-rw-r--r--include/stc/cmap.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index d3281163..d4040e57 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -54,7 +54,7 @@ int main(void) {
#include <stdlib.h>
#include <string.h>
#define _cmap_inits {NULL, NULL, 0, 0, 0.85f}
-typedef struct { MAP_SIZE_T idx; uint_fast8_t hx; } chash_bucket_t;
+typedef struct { MAP_SIZE_T idx; uint8_t hx; } chash_bucket_t;
#endif // CMAP_H_INCLUDED
#ifndef _i_prefix
@@ -288,8 +288,8 @@ STC_DEF void _cx_memb(_clear)(_cx_self* self) {
STC_DEF chash_bucket_t
_cx_memb(_bucket_)(const _cx_self* self, const _cx_rawkey* rkeyptr) {
const uint64_t _hash = i_hash(rkeyptr, sizeof *rkeyptr);
- uint_fast8_t _hx; _cx_size _cap = self->bucket_count;
- chash_bucket_t b = {c_PASTE(fastrange_,MAP_SIZE_T)(_hash, _cap), (uint_fast8_t)(_hash | 0x80)};
+ uint8_t _hx; _cx_size _cap = self->bucket_count;
+ chash_bucket_t b = {c_PASTE(fastrange_,MAP_SIZE_T)(_hash, _cap), (uint8_t)(_hash | 0x80)};
const uint8_t* _hashx = self->_hashx;
while ((_hx = _hashx[b.idx])) {
if (_hx == b.hx) {