diff options
| author | Tyge Løvset <[email protected]> | 2022-10-20 18:55:01 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-10-20 18:55:01 +0200 |
| commit | b40ca18d43d31f997f64de6168ada58c7dfad9b9 (patch) | |
| tree | d9fc575becaa8ad3d401058adb011818842fb50e /include/stc | |
| parent | 14f67d1936fa76be436eaaee739861268ca534f7 (diff) | |
| download | STC-modified-b40ca18d43d31f997f64de6168ada58c7dfad9b9.tar.gz STC-modified-b40ca18d43d31f997f64de6168ada58c7dfad9b9.zip | |
Fixed some inconsistencies, and a minor bug in cmap.
Diffstat (limited to 'include/stc')
| -rw-r--r-- | include/stc/carc.h | 4 | ||||
| -rw-r--r-- | include/stc/cbox.h | 4 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 1 | ||||
| -rw-r--r-- | include/stc/cmap.h | 20 | ||||
| -rw-r--r-- | include/stc/template.h | 3 |
5 files changed, 19 insertions, 13 deletions
diff --git a/include/stc/carc.h b/include/stc/carc.h index 6148a815..94dc9bd6 100644 --- a/include/stc/carc.h +++ b/include/stc/carc.h @@ -78,10 +78,10 @@ int main() { #ifndef _i_prefix #define _i_prefix carc_ #endif -#if !(defined i_cmp || defined i_less) +#if !(defined i_cmp || defined i_less || defined i_val_class) #define _i_no_cmp #endif -#if !(defined i_eq || defined i_hash) +#if !(defined i_eq || defined i_hash || defined i_val_class) #define _i_no_hash #endif #include "template.h" diff --git a/include/stc/cbox.h b/include/stc/cbox.h index 62bb506a..f31c5feb 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -70,10 +70,10 @@ int main() { #ifndef _i_prefix #define _i_prefix cbox_ #endif -#if !(defined i_cmp || defined i_less) +#if !(defined i_cmp || defined i_less || defined i_val_class) #define _i_no_cmp #endif -#if !(defined i_eq || defined i_hash) +#if !(defined i_eq || defined i_hash || defined i_val_class) #define _i_no_hash #endif #include "template.h" diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 52c05693..5ecb42f8 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -111,6 +111,7 @@ #define c_no_atomic (1<<1) #define c_no_clone (1<<2) #define c_no_cmp (1<<3) +#define c_no_hash (1<<4) /* Generic algorithms */ diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 659b89f7..ed8a81c8 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -361,15 +361,17 @@ _cx_memb(_insert_entry_)(_cx_self* self, _cx_rawkey rkey) { #if !defined _i_no_clone STC_DEF _cx_self _cx_memb(_clone)(_cx_self m) { - _cx_value *t = c_alloc_n(_cx_value, m.bucket_count), *dst = t, *m_end = m.table + m.bucket_count; - uint8_t *h = (uint8_t *)memcpy(c_malloc(m.bucket_count + 1), m._hashx, m.bucket_count + 1); - if (!(t && h)) - { c_free(t), c_free(h), t = 0, h = 0, m.bucket_count = 0; } - else - for (; m.table != m_end; ++m.table, ++m._hashx, ++dst) - if (*m._hashx) - *dst = _cx_memb(_value_clone)(*m.table); - m.table = t, m._hashx = h; + if (m.table) { + _cx_value *t = c_alloc_n(_cx_value, m.bucket_count), *dst = t, *m_end = m.table + m.bucket_count; + uint8_t *h = (uint8_t *)memcpy(c_malloc(m.bucket_count + 1), m._hashx, m.bucket_count + 1); + if (!(t && h)) + { c_free(t), c_free(h), t = 0, h = 0, m.bucket_count = 0; } + else + for (; m.table != m_end; ++m.table, ++m._hashx, ++dst) + if (*m._hashx) + *dst = _cx_memb(_value_clone)(*m.table); + m.table = t, m._hashx = h; + } return m; } #endif diff --git a/include/stc/template.h b/include/stc/template.h index f8d9e7b7..000b516e 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -163,6 +163,9 @@ #if c_option(c_no_cmp) #define _i_no_cmp #endif +#if c_option(c_no_hash) + #define _i_no_hash +#endif #if c_option(c_no_clone) || (!defined i_keyclone && (defined i_keydrop || defined i_keyraw)) #define _i_no_clone #endif |
