Towards shared modules: refactor.

This commit is contained in:
Nuno Cruces
2023-03-06 23:41:54 +00:00
parent d291738b81
commit 6c96a019e6
3 changed files with 49 additions and 49 deletions

View File

@@ -42,14 +42,13 @@ func OpenFlags(filename string, flags OpenFlag) (*Conn, error) {
}
func newConn(filename string, flags OpenFlag) (conn *Conn, err error) {
ctx := context.Background()
mod, err := instantiateModule()
if err != nil {
return nil, err
}
defer func() {
if conn == nil {
mod.Close(ctx)
mod.close()
} else {
runtime.SetFinalizer(conn, finalizer[Conn](3))
}
@@ -128,7 +127,7 @@ func (c *Conn) Close() error {
c.handle = 0
runtime.SetFinalizer(c, nil)
return c.mem.mod.Close(c.ctx)
return c.module.close()
}
// Exec is a convenience function that allows an application to run