The title of this question may be a little confusing.
I want to call a C function in python with cffi. It's a compression function. Part of the function looks like this:
int compression_float_3d(float* array, int nx, int ny, int nz)
{
...
void* buffer;
...
// allocate buffer for compressed data
buffer = malloc(bufsize);
...
// compress the array
size = compress(...);
}
In this function, the compressed array is stored in a buffer pointer. Before I call the function, I won't know the size of the compressed array, which I will know after calling it. I want to get the compressed array and don't want to write it into the file. Therefore, I am thinking how to get the buffer pointer from the function. I don't know what I should pass to the function. Or should I change the return type of this function?