Add cJSON_Allocators new style allocator struct

This commit is contained in:
Max Bruckner
2018-03-25 23:32:03 +02:00
parent dd1ba72ce2
commit 98e0b586ca
5 changed files with 89 additions and 51 deletions
+8
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))