|
|
|
@@ -459,13 +459,15 @@ int json_object_object_add_ex(struct json_object* jso, |
|
|
|
struct json_object *const val, |
|
|
|
const unsigned opts) |
|
|
|
{ |
|
|
|
struct json_object *existing_value = NULL; |
|
|
|
struct lh_entry *existing_entry; |
|
|
|
unsigned long hash; |
|
|
|
|
|
|
|
assert(json_object_get_type(jso) == json_type_object); |
|
|
|
|
|
|
|
// We lookup the entry and replace the value, rather than just deleting |
|
|
|
// and re-adding it, so the existing key remains valid. |
|
|
|
json_object *existing_value = NULL; |
|
|
|
struct lh_entry *existing_entry; |
|
|
|
const unsigned long hash = lh_get_hash(jso->o.c_object, (const void *)key); |
|
|
|
hash = lh_get_hash(jso->o.c_object, (const void *)key); |
|
|
|
existing_entry = (opts & JSON_C_OBJECT_ADD_KEY_IS_NEW) ? NULL : |
|
|
|
lh_table_lookup_entry_w_hash(jso->o.c_object, |
|
|
|
(const void *)key, hash); |
|
|
|
@@ -851,11 +853,12 @@ struct json_object* json_object_new_double(double d) |
|
|
|
|
|
|
|
struct json_object* json_object_new_double_s(double d, const char *ds) |
|
|
|
{ |
|
|
|
char *new_ds; |
|
|
|
struct json_object *jso = json_object_new_double(d); |
|
|
|
if (!jso) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
char *new_ds = strdup(ds); |
|
|
|
new_ds = strdup(ds); |
|
|
|
if (!new_ds) |
|
|
|
{ |
|
|
|
json_object_generic_delete(jso); |
|
|
|
@@ -1035,8 +1038,8 @@ int json_object_set_string(json_object* jso, const char* s) { |
|
|
|
} |
|
|
|
|
|
|
|
int json_object_set_string_len(json_object* jso, const char* s, int len){ |
|
|
|
if (jso==NULL || jso->o_type!=json_type_string) return 0; |
|
|
|
char *dstbuf; |
|
|
|
if (jso==NULL || jso->o_type!=json_type_string) return 0; |
|
|
|
if (len<LEN_DIRECT_STRING_DATA) { |
|
|
|
dstbuf=jso->o.c_string.str.data; |
|
|
|
if (jso->o.c_string.len>=LEN_DIRECT_STRING_DATA) free(jso->o.c_string.str.ptr); |
|
|
|
|