From b2a483b9fdd1409fa50476174cfcad05c0490c36 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Fri, 10 Oct 2025 05:41:16 +0200 Subject: [PATCH] Add close function inside destroy --- codex/codex.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/codex/codex.go b/codex/codex.go index a48cb03..bc3a269 100644 --- a/codex/codex.go +++ b/codex/codex.go @@ -30,6 +30,10 @@ package codex return codex_stop(codexCtx, (CodexCallback) callback, resp); } + static int cGoCodexClose(void* codexCtx, void* resp) { + return codex_close(codexCtx, (CodexCallback) callback, resp); + } + static int cGoCodexDestroy(void* codexCtx, void* resp) { return codex_destroy(codexCtx, (CodexCallback) callback, resp); } @@ -252,11 +256,20 @@ func (node CodexNode) Destroy() error { bridge := newBridgeCtx() defer bridge.free() + if C.cGoCodexClose(node.ctx, bridge.resp) != C.RET_OK { + return bridge.callError("cGoCodexClose") + } + + _, err := bridge.wait() + if err != nil { + return err + } + if C.cGoCodexDestroy(node.ctx, bridge.resp) != C.RET_OK { return bridge.callError("cGoCodexDestroy") } - _, err := bridge.wait() + _, err = bridge.wait() return err }