I have a data structure that I want to make a copy of. Here are the details:
struct MyStructA
{
char barney;
char fred;
char foo;
char foobar;
};
struct MyStructB
{
struct MyStructA *widget;
double m1;
double m2;
double m3;
};
int AllocIt(const size_t size, struct MyStructB *item)
{
if((item->widget = (struct MyStructA *)calloc(size * sizeof(struct
MyStructA))) == 0)
return -1;
else
return 0;
}
int CopyIt(struct MyStructB* dest, const struct MyStructB* src)
{
/* problem seems to be that I don't know the size (i.e. "length in
memory" of the src object) - or do I ? - is there a way I can RELIABLY
and CONSISTENTLY derive the size, knowing that it is a multiple of
sizeof(struct MyStructA)) ??? */
}