summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xs.h16
-rw-r--r--xs_version.h2
2 files changed, 13 insertions, 5 deletions
diff --git a/xs.h b/xs.h
index a6e40d5..2a90467 100644
--- a/xs.h
+++ b/xs.h
@@ -1061,14 +1061,15 @@ xs_keyval *xs_keyval_make(xs_keyval *keyval, const xs_str *key, const xs_val *va
1061 1061
1062typedef struct { 1062typedef struct {
1063 int value_offset; /* offset to value (from dict start) */ 1063 int value_offset; /* offset to value (from dict start) */
1064 int next; /* next node in sequential search */ 1064 int next; /* next node in sequential scanning */
1065 int child[4]; /* child nodes in hashed search */ 1065 int child[4]; /* child nodes in hashed search */
1066 char key[]; /* C string key */ 1066 char key[]; /* C string key */
1067} ditem_hdr; 1067} ditem_hdr;
1068 1068
1069typedef struct { 1069typedef struct {
1070 int size; /* size of full dict (_XS_TYPE_SIZE) */ 1070 int size; /* size of full dict (_XS_TYPE_SIZE) */
1071 int first; /* first node for sequential search */ 1071 int first; /* first node for sequential scanning */
1072 int last; /* last node for sequential scanning */
1072 int root; /* root node for hashed search */ 1073 int root; /* root node for hashed search */
1073 /* a bunch of ditem_hdr and value follows */ 1074 /* a bunch of ditem_hdr and value follows */
1074} dict_hdr; 1075} dict_hdr;
@@ -1153,8 +1154,15 @@ xs_dict *xs_dict_set(xs_dict *dict, const xs_str *key, const xs_val *value)
1153 memcpy(dict + di->value_offset, value, vsz); 1154 memcpy(dict + di->value_offset, value, vsz);
1154 1155
1155 /* chain to the sequential list */ 1156 /* chain to the sequential list */
1156 di->next = dh->first; 1157 if (dh->first == 0)
1157 dh->first = end; 1158 dh->first = end;
1159 else {
1160 /* chain this new element to the last one */
1161 ditem_hdr *dil = (ditem_hdr *)(dict + dh->last);
1162 dil->next = end;
1163 }
1164
1165 dh->last = end;
1158 } 1166 }
1159 else { 1167 else {
1160 /* ditem already exists */ 1168 /* ditem already exists */
diff --git a/xs_version.h b/xs_version.h
index fc3b755..ded4335 100644
--- a/xs_version.h
+++ b/xs_version.h
@@ -1 +1 @@
/* 9e8f5cf300ffbf453031f2ec923cef0822a41b41 2025-01-08T16:57:26+01:00 */ /* c317231894f28c39ba45a46f493f124d12a12f3a 2025-01-12T06:56:21+01:00 */