Page 1 of 1

returning a list from C module

Posted: Wed Dec 19, 2018 6:59 am
by vtu93
I am trying to convert an array of floats(fft_test->output) into a list that I can return on a C module.
I had a look through obj.h and mp_obj_new_bytearray seemed like the best choice.

void *fft_output = fft_test->output;
mp_obj_t fft_list = mp_obj_new_bytearray(sizeof(fft_output), fft_output);
return fft_list;

This will return "segmentation fault (core dump)"

Re: returning a list from C module

Posted: Thu Dec 20, 2018 3:35 am
by dhylands
sizeof(fft_output) will be the sizeof the pointer which will be 4 or 8 bytes depending in the CPU you're targeting.

The fact that it segfaults probably points to fft_output not being valid.