This is the headache I'm facing. I'm allocating memory in DLL and freeing it in the program that is using the DLL. So far, it works alright. I agree it is risky, but for your first suggestion, I can't do it because the memory is dynamic, I will never know the exact memory size needed.
Originally Posted by CornedBee
For your second suggestion, it's not possible because the if I free the memory in DLL, then my main program can't receive the array from DLL
For you third suggestion, I think it will have the first problem as the second suggestion
Below is my code which I call the DLL. minemqb is the DLL function. I'm passing in a pointer chain_interact_result, which the function minemqb will point it to the results I needed
minemqb(&chain_interact_result, db, protein[protein_index].chain[chain1]+1, protein[protein_index].chain[chain2]+1, 0, 2, 0, 2, 0);