summaryrefslogtreecommitdiff
path: root/src/BitfieldMan.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-02-06 14:49:22 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-02-06 14:49:22 +0000
commit5b2f8f036eabae5bb607b91e69f0862ec9e2a9ef (patch)
tree546e85527511973a478b6559ef86c3975dc86b9b /src/BitfieldMan.cc
parenta4e7bd7ec4e995852d5413fce4cde3b5ef5e8af1 (diff)
2007-02-06 Tatsuhiro Tsujikawa <tujikawa dot rednoah dot com>
To fix the bug that causes crash on Max OS X: * src/SimpleRandomizer.h (getInstance): Create new instance if the static variable is null. * src/SimpleRandomizer.cc (randomizer): Initialized to 0. * src/BitfieldManFactory.h (getNewFactory): Removed the call to setRandomizer(). To fix the miscalculation of the range of checksum: * src/BitfieldMan.h (isBitSetOffsetRange): New function. * src/BitfieldMan.cc (isBitSetOffsetRange): New function. * src/SegmentMan.cc (tryChunkChecksumValidation): Use BitfieldMan::isBitSetOffsetRange(). Use bitfield->getBlockLength() instead of segment.segmentLength.
Diffstat (limited to 'src/BitfieldMan.cc')
-rw-r--r--src/BitfieldMan.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/BitfieldMan.cc b/src/BitfieldMan.cc
index af8488a4..f142e00a 100644
--- a/src/BitfieldMan.cc
+++ b/src/BitfieldMan.cc
@@ -644,3 +644,24 @@ void BitfieldMan::unsetBitRange(int32_t startIndex, int32_t endIndex)
}
updateCache();
}
+
+bool BitfieldMan::isBitSetOffsetRange(int64_t offset, int64_t length) const
+{
+ if(length <= 0) {
+ return false;
+ }
+ if(totalLength <= offset) {
+ return false;
+ }
+ if(totalLength < offset+length) {
+ length = totalLength-offset;
+ }
+ int32_t startBlock = offset/blockLength;
+ int32_t endBlock = (offset+length-1)/blockLength;
+ for(int32_t i = startBlock; i <= endBlock; i++) {
+ if(!isBitSet(i)) {
+ return false;
+ }
+ }
+ return true;
+}