mirror of
https://github.com/json-c/json-c.git
synced 2026-04-05 13:29:06 +08:00
Merge pull request #393 from besser82/enhancement/unsigned_refcount
json_object_private: Use unsigned 32-bit integer type for refcount
This commit is contained in:
@@ -169,6 +169,9 @@ extern struct json_object* json_object_get(struct json_object *jso)
|
|||||||
{
|
{
|
||||||
if (!jso) return jso;
|
if (!jso) return jso;
|
||||||
|
|
||||||
|
// Don't overflow the refcounter.
|
||||||
|
assert(jso->_ref_count < UINT_FAST32_MAX);
|
||||||
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && defined(ENABLE_THREADING)
|
#if defined(HAVE_ATOMIC_BUILTINS) && defined(ENABLE_THREADING)
|
||||||
__sync_add_and_fetch(&jso->_ref_count, 1);
|
__sync_add_and_fetch(&jso->_ref_count, 1);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ struct json_object
|
|||||||
enum json_type o_type;
|
enum json_type o_type;
|
||||||
json_object_private_delete_fn *_delete;
|
json_object_private_delete_fn *_delete;
|
||||||
json_object_to_json_string_fn *_to_json_string;
|
json_object_to_json_string_fn *_to_json_string;
|
||||||
int _ref_count;
|
uint_fast32_t _ref_count;
|
||||||
struct printbuf *_pb;
|
struct printbuf *_pb;
|
||||||
union data {
|
union data {
|
||||||
json_bool c_boolean;
|
json_bool c_boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user