So there is a problem I am headbanging over two nights in a row:
(tuple1 and tuple2 are void pointers passed to this function)
char *data;
data = (char*) calloc (76, 1);
memcpy(data, tuple1, 32);
memcpy(data+32, tuple2, 44);
The idea is to allocate memory equal to the sum of the sizes of tuple1
and tuple2
(tuple1
is 32 bytes and tuple2
is 44) and then copy the 32 bytes of tuple1
and paste them at the address of data and after that copy the 44 bytes of tuple2
and paste them 32 bytes after the address of data.
The thing is if I copy only tuple1
or only tuple2
it is really copied where it is supposed to be (I am printing data with way too long function to put here), but when I do the two memory copies the first memcpy()
works fine but the second doesn't.
Can anyone help me with this serious problem?