From 9b49e45e9613082ce40433a4603bb836cd62910a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 25 Oct 2009 14:15:22 +0000 Subject: [PATCH] 2009-10-25 Tatsuhiro Tsujikawa Added missing bitfield.cc * src/bitfield.cc --- ChangeLog | 5 +++++ src/bitfield.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/bitfield.cc diff --git a/ChangeLog b/ChangeLog index 7ef8a29c..fc0050de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-10-25 Tatsuhiro Tsujikawa + + Added missing bitfield.cc + * src/bitfield.cc + 2009-10-23 Tatsuhiro Tsujikawa Renamed Util.{cc,h} as util.{cc,h} diff --git a/src/bitfield.cc b/src/bitfield.cc new file mode 100644 index 00000000..30c861e0 --- /dev/null +++ b/src/bitfield.cc @@ -0,0 +1,51 @@ +/* */ +#include "bitfield.h" + +namespace aria2 { + +namespace bitfield { + +void flipBit(unsigned char* data, size_t length, size_t bitIndex) +{ + size_t byteIndex = bitIndex/8; + assert(byteIndex <= length); + unsigned char mask = 128 >> (bitIndex%8); + data[byteIndex] ^= mask; +} + +} // namespace bitfield + +} // namespace aria2