Can't piece together this code
Hello,
Does this code look sane? I'm supposed to be checking mirrored values for card images that will be emulated and I am not sure of the pointer arithmetic performed on LHS, RHS memset values. buf is a fixed with integer pointer malloc'd some multiple of 2, seems to me we're comparing the same memory?
Code:
int check_buf(void *buf, int size, int full_size)
{
if (size / 2 && memcmp(buf, buf + size / 2, size / 2) == 0)
{
if (!check_buf(buf, size / 2, full_size))
{
printf("Mirrored memory.");
assert(0);
}
return 1;
}
else
{
return 0;
}
}
Best