ignore empty clusters when getting first block

Change-Id: I9278efcacc3ea5dcfa584cb0937e39a4004e6947
This commit is contained in:
matthewjheaney
2010-11-15 21:22:57 -05:00
parent 91dbee4b6e
commit 790f639f2f

View File

@@ -3060,11 +3060,7 @@ long Track::GetFirst(const BlockEntry*& pBlockEntry) const
{ {
const Cluster* pCluster = m_pSegment->GetFirst(); const Cluster* pCluster = m_pSegment->GetFirst();
//If Segment::GetFirst returns NULL, then this must be a network for (int i = 0; ; )
//download, and we haven't loaded any clusters yet. In this case,
//returning NULL from Track::GetFirst means the same thing.
for (int i = 0; i < 100; ++i) //arbitrary upper bound
{ {
if (pCluster == NULL) if (pCluster == NULL)
{ {
@@ -3086,7 +3082,13 @@ long Track::GetFirst(const BlockEntry*& pBlockEntry) const
pBlockEntry = pCluster->GetFirst(); pBlockEntry = pCluster->GetFirst();
while (pBlockEntry) if (pBlockEntry == 0) //empty cluster
{
pCluster = m_pSegment->GetNext(pCluster);
continue;
}
for (;;)
{ {
const Block* const pBlock = pBlockEntry->GetBlock(); const Block* const pBlock = pBlockEntry->GetBlock();
assert(pBlock); assert(pBlock);
@@ -3095,8 +3097,16 @@ long Track::GetFirst(const BlockEntry*& pBlockEntry) const
return 0; return 0;
pBlockEntry = pCluster->GetNext(pBlockEntry); pBlockEntry = pCluster->GetNext(pBlockEntry);
if (pBlockEntry == 0)
break;
} }
++i;
if (i >= 100)
break;
pCluster = m_pSegment->GetNext(pCluster); pCluster = m_pSegment->GetNext(pCluster);
} }