bmatsuo / lmdb-go

Bindings for the LMDB C library
BSD 3-Clause "New" or "Revised" License
157 stars 59 forks source link

lmdb: deprecated conversion from pointers to slices #67

Closed bmatsuo closed 8 years ago

bmatsuo commented 8 years ago

The cgo wiki page suggests a different way to turn arrays into slices.

https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices

The current method using the "reflect" package isn't guaranteed to be compatible.

https://godoc.org/reflect#SliceHeader

The docs claims the method is not portable. This may be due to os/arch restrictions on the amount of memory available for use and the slice implementation.

https://github.com/golang/go/blob/6b0688f7421aeef904d40a374bae75c37ba0b8b4/src/runtime/slice.go#L17-L34 https://github.com/golang/go/blob/a03bdc3e6bea34abd5077205371e6fb9ef354481/src/runtime/malloc.go#L151-L164

bmatsuo commented 8 years ago

LMDB has a hard limit on data size, 2^32-1 (0xffffffff). From the above links it seems like it should be ok to make a temporary conversion to *[1<<32 - 1]byte when 'slicing' a db value.