Now you've created a problem if the size of the buffer is less than 2 bytes.
I'd remove the conditional out of the loop. The following should perform correct rotates, both intentionally processing the bytes in the same order, as you had it:
Code:
void shiftl(void *object, size_t size) {
unsigned char *byte, *last;
unsigned char firstBit;
if (size != 0) {
byte = object;
last = byte + size-1;
firstBit = byte[0] >> (CHAR_BIT-1);
while (byte < last) {
byte[0] = (byte[0] << 1) | (byte[1] >> (CHAR_BIT-1));
++byte;
}
(*last) = (*last) << 1 | firstBit;
}
}
void shiftr(void *object, size_t size) {
unsigned char *byte, *end;
unsigned char bit, nextBit;
if (size != 0) {
byte = object;
end = byte + size;
bit = *(end-1) & 1;
while (byte < end) {
nextBit = byte[0] & 1;
byte[0] = (byte[0] >> 1) | (bit << (CHAR_BIT-1));
++byte;
bit = nextBit;
}
}
}