summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c/jv.c13
-rw-r--r--c/jv.h1
2 files changed, 10 insertions, 4 deletions
diff --git a/c/jv.c b/c/jv.c
index c4a5af1c..1d5c9816 100644
--- a/c/jv.c
+++ b/c/jv.c
@@ -58,6 +58,10 @@ jv jv_null() {
return JV_NULL;
}
+jv jv_bool(int x) {
+ return x ? JV_TRUE : JV_FALSE;
+}
+
/*
* Numbers
*/
@@ -617,11 +621,12 @@ static jv* jvp_object_write(jv_complex* object, jvp_string* key) {
if (slot) {
// already has the key
jvp_string_free_p(key);
- } else {
- slot = jvp_object_add_slot(object, key, bucket);
- slot->value = jv_invalid();
+ return &slot->value;
}
- if (slot == 0) {
+ slot = jvp_object_add_slot(object, key, bucket);
+ if (slot) {
+ slot->value = jv_invalid();
+ } else {
jvp_object_rehash(object);
bucket = jvp_object_find_bucket(object, key);
assert(!jvp_object_find_slot(object, key, bucket));
diff --git a/c/jv.h b/c/jv.h
index 8d9ebadb..6872ec5c 100644
--- a/c/jv.h
+++ b/c/jv.h
@@ -52,6 +52,7 @@ jv jv_invalid();
jv jv_null();
jv jv_true();
jv jv_false();
+jv jv_bool(int);
jv jv_number(double);
double jv_number_value(jv);