MSVC: workaround for C2322

This commit is contained in:
Max Bruckner 2017-06-17 14:33:04 +02:00
parent 0d675cb048
commit d1c2e2df4a
1 changed files with 21 additions and 1 deletions

22
cJSON.c
View File

@ -114,7 +114,27 @@ typedef struct internal_hooks
void *(*reallocate)(void *pointer, size_t size);
} internal_hooks;
static internal_hooks global_hooks = { malloc, free, realloc };
#if defined(_MSC_VER)
/* work around MSVC error C2322: '...' address of dillimport '...' is not static */
static void *internal_malloc(size_t size)
{
return malloc(size);
}
static void internal_free(void *pointer)
{
free(pointer);
}
static void *internal_realloc(void *pointer, size_t size)
{
return realloc(pointer, size);
}
#else
#define internal_malloc malloc
#define internal_free free
#define internal_realloc realloc
#endif
static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc };
static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks)
{