Add CountBits() to the server.

Function to count the number of bits set in the given array.

Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
Chase Douglas
2010-10-19 13:37:38 +10:00
committed by Peter Hutterer
parent eaf0b6a4d8
commit fc48a8f9f5
2 changed files with 14 additions and 0 deletions

View File

@@ -418,3 +418,16 @@ FreeInputAttributes(InputAttributes *attrs)
free(attrs);
}
int
CountBits(const uint8_t *mask, int len)
{
int i;
int ret = 0;
for (i = 0; i < len; i++)
if (BitIsOn(mask, i))
ret++;
return ret;
}