Set or clear the bit in the buffer at the given offset
| Return Type | Function name | Arguments |
|---|---|---|
| void | SetBits | (unsigned char*,uint32_t,bool,) |
Declared and defined in file: hzIntset.cpp
Function Logic:
Function body:
void SetBits (unsigned char* pBitbuf)uint32_t nOset, bool bValue,
{
// Category: Bitwise
//
// Set or clear the bit in the buffer at the given offset
//
// Arguments: 1) pBitbuf The buffer
// 2) nOset The offset (is divided by 8)
// 2) bValue The offset (is divided by 8)
//
// Returns: True If the requested bit number is set within the segment
// False If the requested bit number is not set within the segment or it exceeds the segment range (0 - 4095)
_hzfunc("__func__") ;
if (pBitbuf)
{
if (bValue)
{
switch (nOset % 8)
{
case 0: pBitbuf[nOset/8]|= 0x80;break;
case 1: pBitbuf[nOset/8]|= 0x40;break;
case 2: pBitbuf[nOset/8]|= 0x20;break;
case 3: pBitbuf[nOset/8]|= 0x10;break;
case 4: pBitbuf[nOset/8]|= 0x08;break;
case 5: pBitbuf[nOset/8]|= 0x04;break;
case 6: pBitbuf[nOset/8]|= 0x02;break;
case 7: pBitbuf[nOset/8]|= 0x01;break;
}
}
else
{
switch (nOset % 8)
{
case 0: pBitbuf[nOset/8]&= ~0x80;break;
case 1: pBitbuf[nOset/8]&= ~0x40;break;
case 2: pBitbuf[nOset/8]&= ~0x20;break;
case 3: pBitbuf[nOset/8]&= ~0x10;break;
case 4: pBitbuf[nOset/8]&= ~0x08;break;
case 5: pBitbuf[nOset/8]&= ~0x04;break;
case 6: pBitbuf[nOset/8]&= ~0x02;break;
case 7: pBitbuf[nOset/8]&= ~0x01;break;
}
}
}
}