Why is the passed variable "list" after performing the function "test" empty i.e. accessing the elements of list or freeing the pointer list result in a memory leak?
What am I missing?
int test(int** container)
{
int numOfItems = 2;
int* p1;
int* p2;
int j=0;
container = (int**) malloc (sizeof(int*) * numOfItems);
for(j=0;j<numOfItems;j++)
container[j] = (int*) malloc (sizeof(int));
*(container[0]) = 12;
*(container[1]) = 13;
}
int main( int argc, const char* argv[] )
{
int* list;
test(&list);
}