I have a following member function prototype.

Code:
Dtk_Int32 ConvertToGeom(Geometric_set_select_entity **res = NULL) const;
If NULL is passed to the above function it returns the size of the output array;

I tried the following sets of code but I am getting stack corruption around the "entity" variable in each case when the function returns. If I remove the code altogether then there is no corruption and everything works fine.

Set 1:
Code:
Dtk_Int32 size = pLeaderPointer->ConvertToGeom(NULL);
Geometric_set_select_entity *entity = new Geometric_set_select_entity[size];
pLeaderPointer->ConvertToGeom(&entity);
Aussuming that I don't have to do the allocation and the function will:

Set 2:
Code:
Geometric_set_select_entity *entity = NULL;
Dtk_Int32 size = pLeaderPointer->ConvertToGeom(&entity);
The corruption again happens.

So I am in a doubt whether I am doing something wrong or the "ConvertToGeom" function is itself buggy.

Please help.