With the code:
int nsize;
int * buffer;
char TargetBuffer[4096];
const SIZE_T buffersize = (320*240) * sizeof(int);
buffer = (int *) malloc(bufferSize);
// fill buffer with data
nsize = 0;
while(nsize < buffersize)
{
// HERE after some loops i get Access Violation
memcpy(TargetBuffer, buffer + nsize, 4096);
// do stuff with TargetBuffer
nsize += 4096;
}
Why am I get the Access Violation? What should I change?
When you add buffer + nsize you have to realize that you are actually adding buffer + (nsize * (sizeof(int)) since it's a int * when you are doing pointer arithmetic.
So it probably has something to do with it. Try incrementing nsize by nsize += 4096/sizeof(int) or something more clever.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With