diff options
| author | bozo.kopic <bozo@kopic.xyz> | 2022-01-02 16:25:36 +0100 |
|---|---|---|
| committer | bozo.kopic <bozo@kopic.xyz> | 2022-01-02 16:25:36 +0100 |
| commit | 90600e3f0761dcd2858a591c68c62c2fd259a381 (patch) | |
| tree | cdea63b8ee351a51c98df994563835b246170181 /src_c/common.c | |
| parent | 746249269e78e0b2043b24c5d0ee061d03ce3db5 (diff) | |
WIP c implementation
Diffstat (limited to 'src_c/common.c')
| -rw-r--r-- | src_c/common.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src_c/common.c b/src_c/common.c index 403fe87..66b826d 100644 --- a/src_c/common.c +++ b/src_c/common.c @@ -392,8 +392,9 @@ static int read_params(opcut_params_t *params, char *json, jsmntok_t *tokens, } -int opcut_params_init(opcut_params_t *params, opcut_pool_t *panel_pool, - opcut_pool_t *item_pool, opcut_str_t *json) { +int opcut_params_init(hat_allocator_t *a, opcut_params_t *params, + opcut_pool_t *panel_pool, opcut_pool_t *item_pool, + opcut_str_t *json) { params->panel_pool = panel_pool; params->item_pool = item_pool; @@ -405,21 +406,22 @@ int opcut_params_init(opcut_params_t *params, opcut_pool_t *panel_pool, if (tokens_len < 0) return OPCUT_ERROR; - jsmntok_t *tokens = malloc(tokens_len * sizeof(jsmntok_t)); + jsmntok_t *tokens = + hat_allocator_alloc(a, tokens_len * sizeof(jsmntok_t), NULL); if (!tokens) return OPCUT_ERROR; jsmn_init(&parser); tokens_len = jsmn_parse(&parser, json->data, json->len, tokens, tokens_len); if (tokens_len < 0) { - free(tokens); + hat_allocator_free(a, tokens); return OPCUT_ERROR; } size_t pos = 0; int err = read_params(params, json->data, tokens, &pos); - free(tokens); + hat_allocator_free(a, tokens); return err; } |
