for (i = 1, j = 0; i < elements; ++i)
{
- if (compare(bytes + i * width, bytes + j * width) != 0)
- memcpy(bytes + ++j * width, bytes + i * width, width);
+ if (compare(bytes + i * width, bytes + j * width) != 0 &&
+ ++j != i)
+ memcpy(bytes + j * width, bytes + i * width, width);
}
return j + 1;
for (i = 1, j = 0; i < elements; ++i)
{
- if (compare(bytes + i * width, bytes + j * width, arg) != 0)
- memcpy(bytes + ++j * width, bytes + i * width, width);
+ if (compare(bytes + i * width, bytes + j * width, arg) != 0 &&
+ ++j != i)
+ memcpy(bytes + j * width, bytes + i * width, width);
}
return j + 1;