diff --git a/mdbx/cursor.go b/mdbx/cursor.go index 991e2e7..4f10779 100644 --- a/mdbx/cursor.go +++ b/mdbx/cursor.go @@ -158,7 +158,7 @@ func (c *Cursor) Get(setkey, setval []byte, op uint) (key, val []byte, err error err = c.getVal2(setkey, setval, op) } if err != nil { - *c.txn.key = C.MDBX_val{} + c.txn.key = C.MDBX_val{} c.txn.val = C.MDBX_val{} return nil, nil, err } @@ -171,14 +171,14 @@ func (c *Cursor) Get(setkey, setval []byte, op uint) (key, val []byte, err error key = setkey } else { if op != LastDup && op != FirstDup { - key = castToBytes(c.txn.key) + key = castToBytes(&c.txn.key) } } val = castToBytes(&c.txn.val) // Clear transaction storage record storage area for future use and to // prevent dangling references. - *c.txn.key = C.MDBX_val{} + c.txn.key = C.MDBX_val{} c.txn.val = C.MDBX_val{} return key, val, nil @@ -189,7 +189,7 @@ func (c *Cursor) Get(setkey, setval []byte, op uint) (key, val []byte, err error // // See mdb_cursor_get. func (c *Cursor) getVal0(op uint) error { - ret := C.mdbx_cursor_get(c._c, c.txn.key, &c.txn.val, C.MDBX_cursor_op(op)) + ret := C.mdbx_cursor_get(c._c, &c.txn.key, &c.txn.val, C.MDBX_cursor_op(op)) return operrno("mdbx_cursor_get", ret) } @@ -205,7 +205,7 @@ func (c *Cursor) getVal1(setkey []byte, op uint) error { ret := C.mdbxgo_cursor_get1( c._c, k, C.size_t(len(setkey)), - c.txn.key, + &c.txn.key, &c.txn.val, C.MDBX_cursor_op(op), ) @@ -219,7 +219,7 @@ func (c *Cursor) getVal01(setval []byte, op uint) error { ret := C.mdbxgo_cursor_get01( c._c, v, C.size_t(len(setval)), - c.txn.key, + &c.txn.key, &c.txn.val, C.MDBX_cursor_op(op), ) @@ -242,7 +242,7 @@ func (c *Cursor) getVal2(setkey, setval []byte, op uint) error { c._c, k, C.size_t(len(setkey)), v, C.size_t(len(setval)), - c.txn.key, &c.txn.val, + &c.txn.key, &c.txn.val, C.MDBX_cursor_op(op), ) return operrno("mdbx_cursor_get", ret) diff --git a/mdbx/txn.go b/mdbx/txn.go index 92b27b8..5fe477f 100644 --- a/mdbx/txn.go +++ b/mdbx/txn.go @@ -59,7 +59,7 @@ const ( type Txn struct { env *Env _txn *C.MDBX_txn - key *C.MDBX_val + key C.MDBX_val val C.MDBX_val errLogf func(format string, v ...interface{}) @@ -92,13 +92,13 @@ func beginTxn(env *Env, parent *Txn, flags uint) (*Txn, error) { if flags&Readonly == 0 { // In a write Txn we can use the shared, C-allocated key and value // allocated by env, and freed when it is closed. - txn.key = env.ckey + //txn.key = env.ckey } else { // It is not easy to share C.MDBX_val values in this scenario unless // there is a synchronized pool involved, which will increase // overhead. Further, allocating these values with C will add // overhead both here and when the values are freed. - txn.key = new(C.MDBX_val) + //txn.key = new(C.MDBX_val) } } else { // Because parent Txn objects cannot be used while a sub-Txn is active