I have C code, which is a bit of a puzzle. For some reason related to this code, I wonder how I can determine if an object ends up struct on the heap or the stack?
Objects are not created with mallocor calloc. They begin their life in the form of an array. For the purposes of this publication, I will call struct Emp.
Emp myEmp[6];
Objects are sorted and processed in various ways, and at some point the objects are copied and then passed to the pointer to the array. Copying is done through memcpy. Then the objects are introduced like this: Emp* emps_a[6].
Objects come from the copy and are assigned to the above emps_a.
int i;
for( i = 0; i < n; i++ )
{
emps_a[i] = myEmpsCopy + i;
}
, - - . () ... , C.
.