Thanks for the help.

> EncodedData *encode(unsigned char* data, size_t data_size)
> and return &ed.
> Also your struct and CStruct are defining the contents in the reverse
> order.  They must
> match up exactly.
>

I did those two changes:
"""
EncodedData* ed = malloc(sizeof(EncodedData));
ed->data = encbuffer;
ed->crc32 = crc32;
return ed;
"""

And i also changed the CStruct [1] to:

class EncodedData is repr('CStruct') {
    has CArray[uint8] $.data;
    has uint32 $.crc32;
}

I'm not getting a SIGSEGV anymore, however i'm now getting the
following error when trying to "say $_ for $ed.data.list":

Don't know how many elements a C array returned from a library
  in method elems at
/usr/share/perl6/core/sources/8660F65A7B3492675BB3B2058DB30E411A4C4E54
(NativeCall::Types) line 223
  in method list at
/usr/share/perl6/core/sources/8660F65A7B3492675BB3B2058DB30E411A4C4E54
(NativeCall::Types) line 226
  in sub MAIN at bin/uints.p6 line 15
  in block <unit> at bin/uints.p6 line 3


I can access without problems $ed.crc32



[1] - if i change the data type to str i get the error: "String
corruption detected: bad storage type"


Best regards,
David Santiago

Reply via email to