summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-04-26 21:14:52 +0200
committerTyge Løvset <[email protected]>2021-04-26 21:14:52 +0200
commitc214f87196b772ee33c633d6010f90bd7b60a0b6 (patch)
tree1de9775c286aee3cd0fc982ad26d8cfb124b4a85
parent69c859a2fcb5053b6dbca8afe083df3843cec25b (diff)
downloadSTC-modified-c214f87196b772ee33c633d6010f90bd7b60a0b6.tar.gz
STC-modified-c214f87196b772ee33c633d6010f90bd7b60a0b6.zip
BUGFIX in csmap: Silly bug: assumed cmp function returned -1, 0, 1, but can be any number.
-rw-r--r--benchmarks/others/csmap_v1.h4
-rw-r--r--stc/csmap.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/benchmarks/others/csmap_v1.h b/benchmarks/others/csmap_v1.h
index 081886c7..5b1d6acb 100644
--- a/benchmarks/others/csmap_v1.h
+++ b/benchmarks/others/csmap_v1.h
@@ -386,7 +386,7 @@ int main(void) {
up[top++] = it; \
C##X##_rawkey_t r = keyToRaw(KEY_REF_##C(&it->value)); \
if ((c = keyCompareRaw(&r, rkey)) == 0) {res->ref = &it->value; return tn;} \
- it = it->link[(dir = (c == -1))]; \
+ it = it->link[(dir = (c < 0))]; \
} \
tn = c_new(C##X##_node_t); \
res->ref = &tn->value, res->inserted = true; \
@@ -417,7 +417,7 @@ int main(void) {
C##X##_rawkey_t raw = keyToRaw(KEY_REF_##C(&tn->value)); \
C##X##_node_t *tx; int c = keyCompareRaw(&raw, rkey); \
if (c != 0) \
- tn->link[c == -1] = C##X##_erase_r_(tn->link[c == -1], rkey, erased); \
+ tn->link[c < 0] = C##X##_erase_r_(tn->link[c < 0], rkey, erased); \
else { \
if (!*erased) {C##X##_value_del(&tn->value); *erased = 1;} \
if (tn->link[0]->level && tn->link[1]->level) { \
diff --git a/stc/csmap.h b/stc/csmap.h
index fa9d05e0..8d0e7f46 100644
--- a/stc/csmap.h
+++ b/stc/csmap.h
@@ -430,7 +430,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0};
up[top++] = tx; \
RawKey raw = keyToRaw(KEY_REF_##C(&d[tx].value)); \
if ((c = keyCompareRaw(&raw, rkey)) == 0) {res->ref = &d[tx].value; return tn;} \
- dir = (c == -1); \
+ dir = (c < 0); \
tx = d[tx].link[dir]; \
} \
tx = CX##_node_new_(self, 1); d = self->nodes; \
@@ -461,7 +461,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0};
RawKey raw = keyToRaw(KEY_REF_##C(&d[tn].value)); \
CX##_size_t tx; int c = keyCompareRaw(&raw, rkey); \
if (c != 0) \
- d[tn].link[c == -1] = CX##_erase_r_(d, d[tn].link[c == -1], rkey, erased); \
+ d[tn].link[c < 0] = CX##_erase_r_(d, d[tn].link[c < 0], rkey, erased); \
else { \
if (!*erased) {CX##_value_del(&d[tn].value); *erased = 1;} \
if (d[tn].link[0] && d[tn].link[1]) { \