How to pass back to caller function location of reallocated arrays?
Posted on 2006-05-09
I want to write a C function that takes in input two arrays, may do some memory re-allocation, put some data into them and return the pointers to the two (possibly moved) arrays so that they are available to the calling function. The prototype should be like:
AddItemToArrays(char * Array1, char * Array2, char * Item1, char * Item2);
The problem I have is that when the Array1 and Array2 need to be re-allocated, the memory location will change and I am not sure how best to set this up so that the calling function will know about the new locations.
can you suggest what's the best way to do this?