Add cJSON_Allocators new style allocator struct

This commit is contained in:
Max Bruckner
2018-02-01 10:26:58 +01:00
parent 649af9c2c3
commit 440ba84d08
5 changed files with 90 additions and 52 deletions

View File

@@ -78,6 +78,14 @@ typedef struct cJSON_Hooks
void (*free_fn)(void *ptr);
} cJSON_Hooks;
/* new style allocators with userdata (e.g. for pool allocators) */
typedef struct cJSON_Allocators
{
void *(*allocate)(size_t size, void *userdata);
void (*deallocate)(void *pointer, void *userdata);
void *(*reallocate)(void *pointer, size_t size, void *userdata); /* optional */
} cJSON_Allocators;
typedef int cJSON_bool;
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))