I have a struct[4] with inside a pointer. I have to malloc this pointer for all the 4 structs
//Here a simplification of my code that produces the same error:
typedef struct{
int *val;
}test_T;
void testAllocSingle(test_T *in){
in->val = (int *)calloc(10, sizeof(int));
}
void testAlloc(test_T *in){
int i = 0;
for (i=0; i<4; i++){
testAllocSingle(&(in[i]));
}
}
void main(void){
test_T a[4];
test_T b[4];
testAlloc(a);
testAlloc(b);
memcpy(b, a, 4*10*sizeof(int));
//FATAL RUN-TIME ERROR: Array argument too small (16 bytes). Argument must contain at least 160 bytes (160 elements).
}
My allocated array is not visible to main. I'm doing something wrong in passing variables, can anyone tell me where?
Thanks

callocwon't be part of the copy.memcpyis a shallow copy.