parent
548d44d360
commit
04133f0f7c
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue