Closed ssorren closed 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.
Yea, that's actually much cleaner...and more importantly, it works.
Hi @JelteF! Clarify please, who is responsible for cleaning C memory in that case?
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.
casting as (*[1 << 24]byte) causes index out of bounds error and crash when []byte being copied is larger than 1 << 24 (16MB)