On Fri, May 8, 2020 at 8:49 AM David Santiago <deman...@gmail.com> wrote:
> EncodedData* ed = malloc(sizeof(EncodedData)); > ed->data = encbuffer; > ed->crc32 = crc32; > return ed; You're returning a pointer to encbuffer -- make sure the storage for that is kept around somewhere. If it is passed in from Raku, you'll be fine as long as you hold on to the object on that side. Otherwise you might need to allocate/copy it to make sure. > class EncodedData is repr('CStruct') { > has CArray[uint8] $.data; > has uint32 $.crc32; > } That's fine, but CArray[uint8] is just a pointer -- it doesn't know how long the array it is pointing to is. It either needs a sentinel at the end (like the Nul at the end of a C string), or a separate field with a size to figure that out. > Don't know how many elements a C array returned from a library yep Curt