summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cmap.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-10-20 18:55:01 +0200
committerTyge Løvset <[email protected]>2022-10-20 18:55:01 +0200
commitb40ca18d43d31f997f64de6168ada58c7dfad9b9 (patch)
treed9fc575becaa8ad3d401058adb011818842fb50e /include/stc/cmap.h
parent14f67d1936fa76be436eaaee739861268ca534f7 (diff)
downloadSTC-modified-b40ca18d43d31f997f64de6168ada58c7dfad9b9.tar.gz
STC-modified-b40ca18d43d31f997f64de6168ada58c7dfad9b9.zip
Fixed some inconsistencies, and a minor bug in cmap.
Diffstat (limited to 'include/stc/cmap.h')
-rw-r--r--include/stc/cmap.h20
1 files changed, 11 insertions, 9 deletions
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