Val is now passed to helpers directly instead of through extra pointer. #31
Vendored
+1
-1
@@ -80,7 +80,7 @@ main :: proc() {
|
||||
data_val: mdb.Val
|
||||
mdb.panic_on_err(mdb.txn_begin(environment, nil, {}, &txn_handle))
|
||||
mdb.panic_on_err(mdb.get(txn_handle, db_handle, &key_val, &data_val))
|
||||
data_cpy := mdb.blittable_copy(&data_val, int)
|
||||
data_cpy := mdb.blittable_copy(data_val, int)
|
||||
mdb.panic_on_err(mdb.txn_commit(txn_handle))
|
||||
fmt.println("Get result:", data_cpy)
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -186,7 +186,7 @@ blittable_val :: #force_inline proc(val_ptr: ^$T) -> Val {
|
||||
|
||||
// Reads a blittable T out of the LMDB memory map by copying it into caller
|
||||
// storage. The returned T has no lifetime tie to the transaction.
|
||||
blittable_copy :: #force_inline proc(val: ^Val, $T: typeid) -> T {
|
||||
blittable_copy :: #force_inline proc(val: Val, $T: typeid) -> T {
|
||||
fmt.assertf(
|
||||
reflect.has_no_indirections(type_info_of(T)),
|
||||
"blitval_copy: type '%v' contains indirection and cannot be read directly from LMDB",
|
||||
@@ -202,7 +202,7 @@ blittable_copy :: #force_inline proc(val: ^Val, $T: typeid) -> T {
|
||||
// or silently corrupt the database (ENV_WRITEMAP).
|
||||
// MUST NOT be retained past txn_commit, txn_abort, or any subsequent write
|
||||
// operation on the same env — the pointer is invalidated.
|
||||
blittable_view :: #force_inline proc(val: ^Val, $T: typeid) -> ^T {
|
||||
blittable_view :: #force_inline proc(val: Val, $T: typeid) -> ^T {
|
||||
fmt.assertf(
|
||||
reflect.has_no_indirections(type_info_of(T)),
|
||||
"blitval_view: type '%v' contains indirection and cannot be viewed directly from LMDB",
|
||||
@@ -231,7 +231,7 @@ slice_val :: #force_inline proc(s: []$T) -> Val {
|
||||
// MUST be copied (e.g. slice.clone) if it needs to outlive the current
|
||||
// transaction; the view is invalidated by txn_commit, txn_abort, or any
|
||||
// subsequent write operation on the same env.
|
||||
slice_view :: #force_inline proc(val: ^Val, $T: typeid) -> []T {
|
||||
slice_view :: #force_inline proc(val: Val, $T: typeid) -> []T {
|
||||
fmt.assertf(
|
||||
reflect.has_no_indirections(type_info_of(T)),
|
||||
"slice_view: element type '%v' contains indirection and cannot be read directly from LMDB",
|
||||
@@ -253,7 +253,7 @@ string_val :: #force_inline proc(s: string) -> Val {
|
||||
// MUST be copied (e.g. strings.clone) if it needs to outlive the current
|
||||
// transaction; the view is invalidated by txn_commit, txn_abort, or any
|
||||
// subsequent write operation on the same env.
|
||||
string_view :: #force_inline proc(val: ^Val) -> string {
|
||||
string_view :: #force_inline proc(val: Val) -> string {
|
||||
return string((cast([^]u8)val.data)[:val.size])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user