Skip to content

Commit 9b0fb2b

Browse files
authored
Merge pull request json-c#727 from jobol/propo2
Really use prefix JSON_C_OBJECT_ADD_
2 parents 05c5d15 + 8bf3b45 commit 9b0fb2b

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

ChangeLog

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
Next Release 0.16
33
=====================
44

5-
...no changes yet...
6-
5+
Significant changes and bug fixes
6+
---------------------------------
7+
* Introduction of constant JSON_C_OBJECT_ADD_CONSTANT_KEY
8+
as a replacement of JSON_C_OBJECT_KEY_IS_CONSTANT,
9+
JSON_C_OBJECT_KEY_IS_CONSTANT becoming legacy.
710

811
***
912

json_object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ int json_object_object_add_ex(struct json_object *jso, const char *const key,
607607
if (!existing_entry)
608608
{
609609
const void *const k =
610-
(opts & JSON_C_OBJECT_KEY_IS_CONSTANT) ? (const void *)key : strdup(key);
610+
(opts & JSON_C_OBJECT_ADD_CONSTANT_KEY) ? (const void *)key : strdup(key);
611611
if (k == NULL)
612612
return -1;
613613
return lh_table_insert_w_hash(JC_OBJECT(jso)->c_object, k, val, hash, opts);

json_object.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,17 @@ extern "C" {
100100
* key is given as a real constant value in the function
101101
* call, e.g. as in
102102
* json_object_object_add_ex(obj, "ip", json,
103-
* JSON_C_OBJECT_KEY_IS_CONSTANT);
103+
* JSON_C_OBJECT_ADD_CONSTANT_KEY);
104104
*/
105-
#define JSON_C_OBJECT_KEY_IS_CONSTANT (1 << 2)
105+
#define JSON_C_OBJECT_ADD_CONSTANT_KEY (1 << 2)
106+
/**
107+
* This flag is an alias to JSON_C_OBJECT_ADD_CONSTANT_KEY.
108+
* Historically, this flag was used first and the new name
109+
* JSON_C_OBJECT_ADD_CONSTANT_KEY was introduced for version
110+
* 0.16.00 in order to have regular naming.
111+
* Use of this flag is now legacy.
112+
*/
113+
#define JSON_C_OBJECT_KEY_IS_CONSTANT JSON_C_OBJECT_ADD_CONSTANT_KEY
106114

107115
/**
108116
* Set the global value of an option, which will apply to all

linkhash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ int lh_table_resize(struct lh_table *t, int new_size)
546546
unsigned long h = lh_get_hash(new_t, ent->k);
547547
unsigned int opts = 0;
548548
if (ent->k_is_constant)
549-
opts = JSON_C_OBJECT_KEY_IS_CONSTANT;
549+
opts = JSON_C_OBJECT_ADD_CONSTANT_KEY;
550550
if (lh_table_insert_w_hash(new_t, ent->k, ent->v, h, opts) != 0)
551551
{
552552
lh_table_free(new_t);
@@ -599,7 +599,7 @@ int lh_table_insert_w_hash(struct lh_table *t, const void *k, const void *v, con
599599
}
600600

601601
t->table[n].k = k;
602-
t->table[n].k_is_constant = (opts & JSON_C_OBJECT_KEY_IS_CONSTANT);
602+
t->table[n].k_is_constant = (opts & JSON_C_OBJECT_ADD_CONSTANT_KEY);
603603
t->table[n].v = v;
604604
t->count++;
605605

linkhash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ extern int lh_table_insert(struct lh_table *t, const void *k, const void *v);
231231
* @param k a pointer to the key to insert.
232232
* @param v a pointer to the value to insert.
233233
* @param h hash value of the key to insert
234-
* @param opts if set to JSON_C_OBJECT_KEY_IS_CONSTANT, sets lh_entry.k_is_constant
234+
* @param opts if set to JSON_C_OBJECT_ADD_CONSTANT_KEY, sets lh_entry.k_is_constant
235235
* so t's free function knows to avoid freeing the key.
236236
*/
237237
extern int lh_table_insert_w_hash(struct lh_table *t, const void *k, const void *v,

0 commit comments

Comments
 (0)