38 Commits

Author SHA1 Message Date
Simon Sobisch
6aab3da807 fix linkhash breaking -std=c89
making the definition of _LH_INLINE depending on __STDC_VERSION__, not on a specific compiler
2024-10-07 08:16:42 +00:00
Even Rouault
3bb54f97e7 Fix typos in code comments and ChangeLog 2022-02-25 00:14:47 +01:00
Eric Haszlakiewicz
2d2382d709 Add linkhash accessor functions (lh_table_head(), lh_entry_next(), etc...) to pave the way for making the lh_table and lh_entry structure opaque in the future.
Update the docs to mark all members of those structures deprecated, and
 suggest what to use instead.
2021-11-30 03:27:55 +00:00
José Bollo
8bf3b45a29 Really use prefix JSON_C_OBJECT_ADD_*
This change introduces JSON_C_OBJECT_ADD_CONSTANT_KEY
as a replacement of JSON_C_OBJECT_KEY_IS_CONSTANT.

The description of json_object_object_add_ex tells to
look at the flags JSON_C_OBJECT_ADD_* but it is not
for JSON_C_OBJECT_KEY_IS_CONSTANT.

From the point of vue of a developper using json-c,
the function json_object_object_add_ex is mainly used,
not the hash facility, it seems more natural to provide
a regular naming of prefix JSON_C_OBJECT_ADD_CONSTANT_KEY.
2021-10-19 11:18:17 +02:00
Eric Haszlakiewicz
9ca50cf2f8 Issue #709: adjust some include guards to be a bit more json-c specific. 2021-06-02 23:53:23 +00:00
Eric Haszlakiewicz
1c6086a86a Apply the fix from @pointbre in issue #626 to skip "inline" on AIX, but invert the test to make it a little easier to understand. 2020-05-31 03:22:14 +00:00
dota17
8b162c4b89 clang-format the files 2020-04-03 11:39:30 +08:00
Eric Haszlakiewicz
a19031411d Remove the previously deprecated lh_table_lookup() function, in favor of lh_table_lookup_ex(). 2017-12-10 00:27:01 -05:00
Eric Haszlakiewicz
f83cf244cd Remove the previously deprecated bits.h and the lh_abort() function. 2017-12-10 00:25:00 -05:00
Eric Haszlakiewicz
d582d3ae5a Undeprecate the array_list, lh_table and printbuf typedefs, but move each to the corresponding header files. 2017-12-06 23:58:33 -05:00
Eric Haszlakiewicz
8c82f0e5c3 Squash doxygen warnings, and make a few slight improvements to the docs. 2017-12-06 23:53:12 -05:00
Eric Haszlakiewicz
f2f103b986 Add a brief overview of each file to the docs. 2017-12-06 00:20:59 -05:00
Eric Haszlakiewicz
edde8eff9f Issue#353: mark lh_abort as actually deprecated, not just in the docs. 2017-09-07 22:21:29 -04:00
Eric Haszlakiewicz
32f503f738 Issue #359: Don't duplicate lh_get_hash, just omit the "inline" for VS2010. 2017-09-06 23:42:30 -04:00
Haffon
e9f9f14f22 if compile with vs2015, enable the "static inline" declare. 2017-09-07 10:28:26 +08:00
Haffon
3141c3976b 1.make it can been compiled with Visual Studio 2010
2.replace json_object_get/put API with json_object_retain/release, as they operate the reference counter, and confused with array_list_get/put_idx.
3.replace array_list_get/put_idx API with array_list_get/insert to make them more clear to use.
2017-08-22 13:53:47 +08:00
pepevel
0df34b4c96 Support for 64 bit pointers on Windows 2016-09-27 20:12:03 +01:00
Eswar Yaganti
78cf6e63ff linkhash.h: removed redundant params from comments 2016-06-25 23:05:41 +05:30
Eric Haszlakiewicz
595891729e Issue #236: Add -Wcast-qual and fix casts to retain constness.
To better distinguish between entry->k and entry->v being const within linkhash, but non-const outside, add lh_entry_v() and lh_entry_k() accessors.
Make lh_entry->k const.
2016-06-11 18:19:39 +00:00
Eric Haszlakiewicz
980cdd61be Merge commit '2be921d88376e78f84d79aafa6db2714da804e59' 2015-12-08 20:51:06 -06:00
Eric Haszlakiewicz
12916e229c Merge pull request #196 from rgerhards/improve-performance
Performance improvements
2015-09-28 22:25:29 -04:00
Rainer Gerhards
1ae4b50bde remove unneeded data items from hashtable code
These items were used for statistics tracking, but no code at all
exists to consume them. By removing them we save

a) space
   because they counters required space, and did so in each and every
   json object

b) performance
   because calloc() needs to write less data and the counters are
   no longer maintained; cache performance can be better, load
   on OS main memory is lighter

We could conditionally enable/disable these counters, but I have not
done this they were really nowhere used and it looked more like a
left-over from the import of hashtable code.
2015-09-23 12:40:57 +02:00
Rainer Gerhards
8f8d03df46 add perllike hash function for strings
This also adds a new API json_global_set_string_hash() which permits
to select the hash function. The default one is the only one that was
previously present. So there are no changes to existing apps, and the
new hash function needs to be explicitely be opted in. Especially for
smaller strings, the perllike functions seems to be around twice as
fast as the other one, with similarly good results in value distribution.
2015-09-23 12:23:09 +02:00
Rainer Gerhards
2d549662be add json_object_object_add_ex() API
This provides more control over some detail aspects, many
of which are performance related.
2015-09-23 09:43:00 +02:00
Rainer Gerhards
d8e44dc685 reduce duplicate hash computation in json_object_object_add()
This can be a very considerable performance saver.
2015-09-22 19:07:30 +02:00
Michael Vetter
fcf5ad1bd6 Remove trailing whitespace 2014-08-26 14:48:59 +02:00
Michael Clark
64e36901a0 Patch to address the following issues:
* CVE-2013-6371: hash collision denial of service
* CVE-2013-6370: buffer overflow if size_t is larger than int
2014-04-09 13:48:21 +08:00
Greg Hazel
cca74c6de6 add json_object_object_length 2013-01-11 01:36:55 -08:00
Alexander Klauer
2be921d883 Fixed json_object_object_add().
* Return value of json_object_object_add() changed from void to int.
  Return value now indicates success or failure.

* Check whether allocations are successful.

* Do not exit program from within the library.
2013-01-08 14:24:21 +01:00
Keith Derrick
4a2cd966f5 Add NULL-safe lookup function
New lh_table_lookup_ex() method protects itself against null pointers
and invalid objects being passed in.
2012-04-12 11:47:56 -07:00
Eric Haszlakiewicz
64c0ca3690 Define a LH_LOAD_FACTOR constant and note the range that it can be set to.
Change the resize check from "count > size" to "count >= size" to avoid a
potential infinite loop with high load factors and a full hash table.
2012-03-31 17:33:58 -05:00
Michael Clark
aaec1ef3c5 * Don't use this as a variable, so we can compile with a C++ compiler
* Add casts from void* to type of assignment when using malloc 
  * Add #ifdef __cplusplus guards to all of the headers
  * Add typedefs for json_object, json_tokener, array_list, printbuf, lh_table
    Michael Clark, <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@33 327403b1-1117-474d-bef2-5cb71233fd97
2009-02-25 02:31:32 +00:00
Michael Clark
68cafad078 Add const correctness to public interfaces
Gerard Krol, g dot c dot krol at student dot tudelft dot nl

Update version number to 0.9



git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@27 327403b1-1117-474d-bef2-5cb71233fd97
2009-01-06 22:56:57 +00:00
Michael Clark
14862b1ef3 Patch allows for json-c compile with -Werror and not fail due to
-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
Geoffrey Young, geoff at modperlcookbook dot org



git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@20 327403b1-1117-474d-bef2-5cb71233fd97
2007-12-07 02:50:42 +00:00
Michael Clark
837240f75f * Fix bug in escaping of control characters
Johan Bj�rklund, johbjo09 at kth dot se
  * Remove include "config.h" from headers (should only
    be included from .c files)
    Michael Clark <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@12 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:25 +00:00
Michael Clark
f6a6e486ff * Make headers C++ compatible by change *this to *obj
* Add ifdef C++ extern "C" to headers
  * Use simpler definition of min and max in bits.h
    Larry Lansing, llansing at fuzzynerd dot com

  * Remove automake 1.6 requirement
  * Move autogen commands into autogen.sh. Update README
  * Remove error pointer special case for Windows
  * Change license from LGPL to MIT
    Michael Clark <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@10 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:23 +00:00
Michael Clark
4504df7117 * printbuf.c - C. Watford (christopher dot watford at gmail dot com)
Added a Win32/Win64 compliant implementation of vasprintf
  * debug.c - C. Watford (christopher dot watford at gmail dot com)
    Removed usage of vsyslog on Win32/Win64 systems, needs to be handled
    by a configure script
  * json_object.c - C. Watford (christopher dot watford at gmail dot com)
    Added scope operator to wrap usage of json_object_object_foreach, this
    needs to be rethought to be more ANSI C friendly
  * json_object.h - C. Watford (christopher dot watford at gmail dot com)
    Added Microsoft C friendly version of json_object_object_foreach
  * json_tokener.c - C. Watford (christopher dot watford at gmail dot com)
    Added a Win32/Win64 compliant implementation of strndup
  * json_util.c - C. Watford (christopher dot watford at gmail dot com)
    Added cast and mask to suffice size_t v. unsigned int conversion
    correctness
  * json_tokener.c - sign reversal issue on error info for nested object parse
    spotted by Johan Bj�rklund (johbjo09 at kth.se)
  * json_object.c - escape " in json_escape_str
  * Change to automake and libtool to build shared and static library
    Michael Clark <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@4 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:20 +00:00
Michael Clark
f0d08887b8 import of version 0.1
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@2 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:18 +00:00