From b88e3cb9e61aaa151d2072879e3382cb3af3485e Mon Sep 17 00:00:00 2001 From: 0scar Date: Mon, 14 Aug 2023 11:23:54 +0200 Subject: Duplicate function names instead of copying pointers --- src/engine.c | 7 ++++--- src/state.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/engine.c b/src/engine.c index d6064de..72dcd27 100644 --- a/src/engine.c +++ b/src/engine.c @@ -723,6 +723,7 @@ void engine_input_ctx_push(i_ctx *ctx) { GLOBAL_PLATFORM->bindings = calloc(8, sizeof(i_ctx*)); GLOBAL_PLATFORM->bindings_sz = 8; } + if (GLOBAL_PLATFORM->bindings_len + 1 >= GLOBAL_PLATFORM->bindings_sz) { void* m = realloc(GLOBAL_PLATFORM->bindings, GLOBAL_PLATFORM->bindings_sz + 8); if (m == NULL) { @@ -732,8 +733,7 @@ void engine_input_ctx_push(i_ctx *ctx) { GLOBAL_PLATFORM->bindings_sz += 8; } - /* - LOG("Bindings in ctx:"); + LOG("Bindings in ctx[%d]:", GLOBAL_PLATFORM->bindings_len); for (isize i = 0; i < ctx->len; i++) { switch (ctx->bindings[i].action.type) { case InputType_error: @@ -753,12 +753,13 @@ void engine_input_ctx_push(i_ctx *ctx) { break; } } - */ + GLOBAL_PLATFORM->bindings[GLOBAL_PLATFORM->bindings_len++] = ctx; } void engine_input_ctx_pop(void) { if (GLOBAL_PLATFORM->bindings == NULL || GLOBAL_PLATFORM->bindings_sz == 0) return; + GLOBAL_PLATFORM->bindings_len--; } void engine_input_ctx_reset(void) { diff --git a/src/state.c b/src/state.c index 595b708..ceb21e6 100644 --- a/src/state.c +++ b/src/state.c @@ -222,14 +222,14 @@ i_ctx* i_ctx_dup(i_ctx **ctx, usize ctx_len) { bb[cumsum] = BindActionLazy( b[i].scancode, b[i].scancode_alt, - b[i].action.action.callback_str); + strdup(b[i].action.action.callback_str)); break; case InputType_state: bb[cumsum] = BindStateLazy( b[i].scancode, b[i].scancode_alt, - b[i].action.state.activate_str, - b[i].action.state.deactivate_str); + strdup(b[i].action.state.activate_str), + strdup(b[i].action.state.deactivate_str)); break; case InputType_range: default: -- cgit v1.3