I have this struct:
struct result {
int position;
int *taken;
};
struct result get_result(int pos, int take[]){
struct result res;
res.position = pos;
res.taken = take;
return res;
}
Which I call in a function:
struct result get_taken_values(){
//some code
int position = 0;
int* chosen = calloc(9, sizeof(int));
//some more code
struct result res;
res.position = position;
res.taken = chosen;
return res;
}
If I were to use this in main, I would simply call free(res.taken) in the end
.
But I'm making this into a shared library using:
gcc -fPIC -c get_taken_values.c
ld -shared -soname libtest.so.1 -o my_library.so -lc get_taken_values.o
I'll be using this library in Python using ctypes.
Do I need to free the calloc, if so how do I do it?