REM:
1. Add struct to json init function .
This commit is contained in:
ChenLing 2019-07-01 14:28:19 +08:00
parent 548d44d360
commit 04133f0f7c
1 changed files with 20 additions and 2 deletions

View File

@ -81,8 +81,26 @@ extern "C" {
S2J_STRUCT_GET_STRUCT_ELEMENT(child_struct, to_struct, child_json, from_json, type, element) S2J_STRUCT_GET_STRUCT_ELEMENT(child_struct, to_struct, child_json, from_json, type, element)
/* s2j.c */ /* s2j.c */
extern S2jHook s2jHook; //extern S2jHook s2jHook;
void s2j_init(S2jHook *hook);
S2jHook s2jHook = {
.malloc_fn = malloc,
.free_fn = free,
};
static void s2j_init(S2jHook *hook)
{
/* initialize cJSON library */
cJSON_InitHooks((cJSON_Hooks *)hook);
/* initialize hooks */
if (hook) {
s2jHook.malloc_fn = (hook->malloc_fn) ? hook->malloc_fn : malloc;
s2jHook.free_fn = (hook->free_fn) ? hook->free_fn : free;
} else {
s2jHook.malloc_fn = malloc;
s2jHook.free_fn = free;
}
}
#ifdef __cplusplus #ifdef __cplusplus
} }