json: Allow to compile with libgpg-error < 1.28

* src/cJSON.c: Use gpgrt fucntion only if available.
--

We have a hack in gpgme-json to allow building with older libgpg-error
versions.  That whole thing will not work but the instead the binary
will print an error at runtime that it needs to be build with a newer
libgcrypt.  There was a little bug here for the Debian packages
libgpg-error versions which failed to build cJSON.  cJSON is only
needed be the full gpgme-json but nevertheless the Makefile wants to
build it.  The fix is straightforward.

GnuPG-bug-id: 3971
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-06-05 09:40:17 +02:00
parent 897423422b
commit 998fec8a4f
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -41,13 +41,13 @@
#include "cJSON.h" #include "cJSON.h"
/* We use malloc function wrappers from gpgrt (aka libgpg-error). */ /* We use malloc function wrappers from gpgrt (aka libgpg-error). */
#if 1 #if GPGRT_VERSION_NUMBER >= 0x011c00 /* 1.28 */
# include <gpgrt.h> # include <gpgrt.h>
# define xtrymalloc(a) gpgrt_malloc ((a)) # define xtrymalloc(a) gpgrt_malloc ((a))
# define xtrycalloc(a,b) gpgrt_calloc ((a), (b)) # define xtrycalloc(a,b) gpgrt_calloc ((a), (b))
# define xtrystrdup(a) gpgrt_strdup ((a)) # define xtrystrdup(a) gpgrt_strdup ((a))
# define xfree(a) gpgrt_free ((a)) # define xfree(a) gpgrt_free ((a))
#else #else /* Without gpgrt (aka libgpg-error). */
# define xtrymalloc(a) malloc ((a)) # define xtrymalloc(a) malloc ((a))
# define xtrycalloc(a,b) calloc ((a), (b)) # define xtrycalloc(a,b) calloc ((a), (b))
# define xtrystrdup(a) strdup ((a)) # define xtrystrdup(a) strdup ((a))