Add close function inside destroy

This commit is contained in:
Arnaud 2025-10-10 05:41:16 +02:00
parent 9d8e6f2743
commit b2a483b9fd
No known key found for this signature in database
GPG Key ID: 20E40A5D3110766F

View File

@ -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
}