Home GnuPG
Diffusion GPGME 81c90d0cd0f9

core: Adjust cJSON code for use in GPGME.

Description

core: Adjust cJSON code for use in GPGME.

* src/cJSON.c: Remove util.h.  Use gpgrt alloc functions.
(cJSON_Delete): Do not clobber ERRNO.
(cJSON_AddItemToObject): Return OBJECT or NULL.
(cJSON_AddNullToObject): New.
(cJSON_AddTrueToObject): New.
(cJSON_AddFalseToObject): New.
(cJSON_AddBoolToObject): New.
(cJSON_AddNumberToObject): New.
(cJSON_AddStringToObject): New.
* src/cJSON.h (cJSON__h): Replace macro by cJSON_h for C compliance.
(cJSON_AddNullToObject): Remove macro.
(cJSON_AddTrueToObject): Remove macro.
(cJSON_AddFalseToObject): Remove macro.
(cJSON_AddBoolToObject): Remove macro.
(cJSON_AddNumberToObject): Remove macro.
(cJSON_AddStringToObject): Remove macro.

The gpgrt malloc functions are used so that we can easily mix memory
returned by gpgrt (e.g. es_read_line) with memory returned from the
JSON function. In general that is not needed but on Windows it makes
a difference if the gpgme DLL is linked to a different C runtime
than the application.

The macros have been replaced to allow error checking (i.e out of
core) for these functions. More error checking should be implemented
instead of silently creating objects which are not as requested.

  • Signed-off-by: Werner Koch <wk@gnupg.org>

Details

Provenance
wernerAuthored on Mar 14 2018, 11:24 AM
Parents
rM8eb08b318913: core: Import cJSON code from the payproc project.
Branches
Unknown
Tags
Unknown