Hi all,
I have a serious trouble to which I found no explanation, if someone can help me this would save me really:
In my code I have lots of structures. I try to make tables of structures and then get access to elements of the structures to use them all along my code: here is an example to clarify things
Net is part of another structure called Switch and Fabric itself is a composed structure.
I have done the following
The compilation returns a segmentation fault because aSwitch->net.closfabr ic is NULL (0) .
surprisingly, in other codes the same analogy of using tables made of double pointers works perfectly with no problems and I have no problem of core dumped and NULL pointers.
I am lost and I cannot understand why am I getting this problem. It is the case whenever I try to use large dimension tables (tab *** struct for example)
Regards,
Monson
I have a serious trouble to which I found no explanation, if someone can help me this would save me really:
In my code I have lots of structures. I try to make tables of structures and then get access to elements of the structures to use them all along my code: here is an example to clarify things
Code:
typedef struct {
Fabric **closfabric;
}Network;
I have done the following
Code:
aSwitch->net.closfabric = (Fabric **)malloc(3* sizeof(Fabric *)); aSwitch->net.closfabric[0] = (Fabric *)malloc(m * sizeof(Fabric )); aSwitch->net.closfabric[1] = (Fabric *)malloc(k * sizeof(Fabric )); aSwitch->net.closfabric[2] = (Fabric *)malloc(m * sizeof(Fabric ));
surprisingly, in other codes the same analogy of using tables made of double pointers works perfectly with no problems and I have no problem of core dumped and NULL pointers.
I am lost and I cannot understand why am I getting this problem. It is the case whenever I try to use large dimension tables (tab *** struct for example)
Regards,
Monson
Comment