summaryrefslogtreecommitdiff
path: root/json_object.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fixes various Wreturn-type and Wimplicit-fallthrough errors on Mingw-w64Jehan2020-03-161-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a recent regression since commit 6359b798479d379a3202e02c6a938d9b40c0d856 which added various assert(0) calls (often replacing return-s). With Ming-W64 compiler, json-c build was failing with various errors of the sort: > /home/jehan/dev/src/json-c/json_object.c: In function 'json_object_int_inc': > /home/jehan/dev/src/json-c/json_object.c:841:1: error: control reaches end of non-void function [-Werror=return-type] > 841 | } > | ^ > In file included from /home/jehan/dev/src/json-c/json_object.c:17: > /home/jehan/dev/src/json-c/json_object.c: In function 'json_object_get_double': > /home/jehan/.local/share/crossroad/roads/w64/json-c/include/assert.h:76:4: error: this statement may fall through [-Werror=implicit-fallthrough=] > 76 | (_assert(#_Expression,__FILE__,__LINE__),0)) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > /home/jehan/dev/src/json-c/json_object.c:1070:7: note: in expansion of macro 'assert' > 1070 | assert(0); > | ^~~~~~ > /home/jehan/dev/src/json-c/json_object.c:1072:3: note: here > 1072 | case json_type_boolean: > | ^~~~ The problem is that Mingw-w64 does not consider assert() as a noreturn (even assert(0)), because it has to be compatible by Microsoft libraries. See the discussion here: https://sourceforge.net/p/mingw-w64/bugs/306/ Instead let's create a new json_abort() function which is basically just an abort() function with an optional message, for such cases where abortion was non-conditional (using assert() and using the assertion condition as a message here was clearly a misuse of the function). And mark json_abort() as 'noreturn', as well as 'cold' for optimization purpose (this is code we expect to never run, unless there is a bug, that is). Finally let's use this json_abort() instead of previous misused assert() calls.
* Follow up the PR#542: improve assert() calls, simplify code in ↵Eric Haszlakiewicz2020-03-021-21/+18
| | | | json_object_equal().
* update json_object.c and testcase, delete json_object_uint_inc()dota172020-02-281-48/+19
|
* modify partial functions and testcase, in order to support automatic ↵dota172020-02-281-33/+79
| | | | conversion for int64/uint64
* modify the json_object, replace c_int64/c_uint64 with struct{union{int64, ↵dota172020-02-271-66/+86
| | | | uint64},...}
* add uint64 data to json-cdota172020-02-251-0/+95
|
* Issue #539: use a internal-only serializer function in ↵Eric Haszlakiewicz2020-02-141-3/+16
| | | | json_object_new_double_s() to avoid potential conflicts with user code that uses the json_object_userdata_to_json_string serializer. Also, document the serializer-resetting behavior of json_object_set_double().
* Issue #539: reset the serializer when json_object_set_double() is called and ↵Eric Haszlakiewicz2020-02-131-0/+2
| | | | the current serializer is the one that json_object_new_double_s() used.
* add json_object_new_nulldota172020-01-201-0/+5
|
* Fix some Windows compile issues, add JSON_EXPORT's, fix bogus character ↵Eric Haszlakiewicz2019-11-231-1/+1
| | | | escapes, define __func__ and omit unistd.h if needed.
* Add an explicit cast to double to squash a -Wimplicit-int-float-conversion ↵Eric Haszlakiewicz2019-08-121-1/+3
| | | | | | | | warning. Though we will no longer be comparing exactly against INT64_MAX, this is ok because any value of that magnitude stored in a double will *also* have been rounded up, so the comparison will work appropriately.
* Issue #486: append a missing ".0" to negative double values too.Eric Haszlakiewicz2019-05-281-3/+8
|
* Merge pull request #453 from darjankrijan/masterEric Haszlakiewicz2018-12-111-4/+4
|\ | | | | Fixed misalignment in JSON string due to space after \n being printed...
| * Removed spaces after \n for arrays as wellDarjan Krijan2018-11-211-2/+2
| |
| * Fixed misalignment in JSON string due to space after \n being printed when ↵Darjan Krijan2018-11-201-2/+2
| | | | | | | | choosing JSON_C_TO_STRING_SPACED together with JSON_C_TO_STRING_PRETTY in json_object_array_to_json_string
* | Merge pull request #454 from ramiropolla/json_object_privateEric Haszlakiewicz2018-11-301-1/+1
|\ \ | | | | | | json_object_private: save 8 bytes in struct json_object in 64-bit arc…
| * | json_object_private: save 8 bytes in struct json_object in 64-bit architecturesRamiro Polla2018-11-241-1/+1
| |/ | | | | | | | | | | | | - there is no need for _ref_count to be uint_fast32_t (the compiler might decide to use a 64-bit int). make it uint32_t instead. - reorder the 32-bit integer fields (o_type and _ref_count) so that there is no wasted 4-byte gap after each of them.
* | Merge pull request #461 from andy5995/issue_422Eric Haszlakiewicz2018-11-281-2/+9
|\ \ | | | | | | json_object.c:set errno in json_object_get_double()
| * | json_object.c:set errno in json_object_get_double()andy59952018-11-261-2/+9
| |/ | | | | | | closes #422
* | json_object.h:document json_object_new_string_len()andy59952018-11-271-1/+1
|/ | | | | | I also added a couple trivial, but related, suggestions. closes #460
* Issue #407: fix incorrect casts in calls to ctype functions (isdigit and ↵Eric Haszlakiewicz2018-03-251-1/+1
| | | | isspace) so we don't crash when asserts are enabled on certain platforms and characters > 128 are parsed.
* PR#394: fix breakage with VS build.Eric Haszlakiewicz2017-12-241-1/+1
|
* PR#394: don't always append the ".0" if the double value rounds to zero ↵Eric Haszlakiewicz2017-12-241-27/+43
| | | | | | because some custom formats *will* include it (e.g. %.2f). Also try to accomodate formats to explicitly exclude the decimal (e.g. %.0f).
* Remove the TRUE and FALSE defines.Eric Haszlakiewicz2017-12-231-4/+4
|
* json_object_private: Use unsigned 32-bit integer type for refcountBjörn Esser2017-12-171-0/+3
|
* json_object: Avoid invalid free (and thus a segfault) when ref_count gets < 0Björn Esser2017-12-141-0/+5
|
* Apply gcc's "const" attribute to the json_c_object_sizeof() function as an ↵Eric Haszlakiewicz2017-12-121-1/+1
| | | | optimizer hint. Also, rename that function from json_object_sizeof().
* json_object: Add size_t json_object_sizeof()Björn Esser2017-12-111-0/+5
|
* Make sure to include the "*" on function pointer arguments to avoid a ↵Eric Haszlakiewicz2017-12-041-1/+1
| | | | warnings from VS2015. See also PR#384.
* Update json_object.cssrlive2017-12-041-2/+2
|
* In json_object_deep_copy(), copy over _userdata, at least for ↵Eric Haszlakiewicz2017-11-291-59/+122
| | | | json_type_string's with the default serializer set, and provide a way for people using custom serializers to provide a custom shallow_copy method.
* Rename _set_last_err() to _json_c_set_last_err().Eric Haszlakiewicz2017-11-291-2/+2
|
* Merge branch 'json_deep_copy' of https://github.com/commodo/json-c into ↵Eric Haszlakiewicz2017-11-291-0/+103
|\ | | | | | | commodo-json_deep_copy
| * json_object: implement json_object_deep_copy()Alexandru Ardelean2017-11-271-0/+103
| | | | | | | | | | | | | | | | Because doing `json_tokener_parse(json_object_get_string(src))` feels sloppy, dirty, and makes me want to cry at night sometimes. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* | Rename json_object_add_int() to json_object_int_inc() and eliminate the ↵Eric Haszlakiewicz2017-11-271-15/+1
|/ | | | "int64" variant since we store 64-bit values internally anyway.
* Add json_object_add_int functionsJuraj Vijtiuk2017-09-141-0/+26
|
* Fix double to int cast overflow in json_object_get_int64.Kurt Schwehr2017-09-111-0/+4
| | | | Found with autofuzz in GDAL
* Add long long 64-bit checkJason King2017-09-081-0/+4
|
* rollback api to 0.12Haffon2017-09-071-7/+7
|
* Merge pull request #2 from json-c/masterHaffon2017-09-071-18/+30
|\ | | | | merge upstream
| * Undo a bit of 2d1da5ab: handle per-thread formats for double serialization, ↵Eric Haszlakiewicz2017-09-051-4/+4
| | | | | | | | even if --enable-threading wasn't specified.
| * Add a --enable-threading configure option, and only use the (slower) ↵Eric Haszlakiewicz2017-09-031-6/+6
| | | | | | | | __sync_add_and_fetch()/__sync_sub_and_fetch() function when it is specified.
| * Explicitly check for GCC's atomic functions instead of depending on the ↵Eric Haszlakiewicz2017-09-021-2/+8
| | | | | | | | | | | | __GNUC__ define. Add a comment mentioning the limitation even though the _ref_count value is hanled atomically.
| * Merge branch 'pull-211'Eric Haszlakiewicz2017-09-021-14/+20
| |\ | | | | | | | | | This is EmielBruijntes' "Atomic updates for the refcount"
| | * subtract first, then retrieve valueEmiel Bruijntjes2015-11-281-1/+1
| | |
| | * added tabs instead of spaces to be compatible with rest of codeEmiel Bruijntjes2015-11-271-8/+8
| | |
| | * update indentationEmiel Bruijntjes2015-11-271-0/+2
| | |
| | * reference increment and decrement is now atomic (when using a GCC compatible ↵Emiel Bruijntjes2015-11-271-14/+18
| | | | | | | | | | | | compiler), which allows passing json objects between threads
* | | Merge pull request #1 from json-c/masterHaffon2017-08-301-7/+5
|\ \ \ | |/ / | | | want to merge the original repository
| * | PR#331: for Visual Studio, use a snprintf/vsnprintf wrapper that ensures the ↵Eric Haszlakiewicz2017-08-251-7/+1
| | | | | | | | | | | | string is terminated.