tecbot / gorocksdb

gorocksdb is a Go wrapper for RocksDB
http://rocksdb.org
MIT License
940 stars 269 forks source link

cByteSlice fix #142

Closed ssorren closed 6 years ago

ssorren commented 6 years ago

casting as (*[1 << 24]byte) causes index out of bounds error and crash when []byte being copied is larger than 1 << 24 (16MB)

JelteF commented 6 years ago

I think it's better to use the C.CBytes function from the stdlib. That would make the function a lot simpler as well.

ssorren commented 6 years ago

Yea, that's actually much cleaner...and more importantly, it works.

shilkin commented 6 years ago

Hi @JelteF! Clarify please, who is responsible for cleaning C memory in that case?

ssorren commented 6 years ago

The caller is responsible for deallocation as in the current code. Right now, there is just a malloc being performed. In C.CBytes, the array is initialized with a malloc as well.