I'm facing a really weird phenomenon of memcpy
. I've allocated a data pointer with 2GB size, but it seems I can't do memcpy
when my offset to the pointer is more than 1666800 bytes. Here is the code
dataMem = (struct dataRecord*) malloc(memsize * 1000000); // where memsize is 2000
... loop condition ...
{
memcpy(dataMem + (dataCount * sizeof(struct dataRecord)), mesg, sizeof(struct dataRecord));
dataCount++;
}
where sizeof(struct dataRecord)
is 1200 bytes, and the dataCount
is 1389. It supposed to be dataMem + 1666800
and the offset still far from 2000000000, as allocated before.
I really confused about this and have no clue.