对于memmove, memcpy等c语言内存操作函数你一定很熟悉吧, 如果不知道, just go -> search
废话少说直接进入话题.
给你一个函数
static void shiftBitToLow(uchar bitarray[], const uint bitleng, uint leftbitshift)
目的是将内存bitarray向低位移动leftbitshift个位, 新进来的内存都设置为bit 1,
暂且假设( leftbitshift< 16 < bitleng ), 注意性能!
//move bit from [leftbitshift, leftbitshift + bitleng) to [0, bitleng)
static void shiftBitToLow(uchar bitarray[], const uint bitleng, uint leftbitshift)
{
assert(leftbitshift <= 16 && leftbitshift < bitleng);
if (leftbitshift % 8 == 0) {
memcpy(bitarray, bitarray + leftbitshift / 8, bitleng / 8 + 32);
} else {
uint* plowdword = (uint*)bitarray + leftbitshift / 8;
//uint* phighword = (uint*)(bitarray + leftbitshift / 8 + 2);
leftbitshift %= 16;