From: Rosen Penev Date: Sun, 2 Oct 2022 20:49:09 +0000 (-0700) Subject: nullptr + const changes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dae2c16882b1c483c926ae065f93afa5fb180bb7;p=libmatroska nullptr + const changes Remove nullptr comparison. Just use bool. Signed-off-by: Rosen Penev --- diff --git a/matroska/KaxBlock.h b/matroska/KaxBlock.h index 14d7a55..9e22829 100644 --- a/matroska/KaxBlock.h +++ b/matroska/KaxBlock.h @@ -69,7 +69,7 @@ class MATROSKA_DLL_API DataBuffer { if (bInternalBuffer) { myBuffer = new (std::nothrow) binary[mySize]; - if (myBuffer == nullptr) + if (!myBuffer) bValidValue = false; else memcpy(myBuffer, aBuffer, mySize); @@ -85,8 +85,8 @@ class MATROSKA_DLL_API DataBuffer { virtual uint32 Size() const {return mySize;}; bool FreeBuffer(const DataBuffer & aBuffer) { bool bResult = true; - if (myBuffer != nullptr && bValidValue) { - if (myFreeBuffer != nullptr) + if (myBuffer && bValidValue) { + if (myFreeBuffer) bResult = myFreeBuffer(aBuffer); if (bInternalBuffer) delete [] myBuffer; @@ -118,7 +118,7 @@ class MATROSKA_DLL_API SimpleDataBuffer : public DataBuffer { static bool myFreeBuffer(const DataBuffer & aBuffer) { auto _Buffer = static_cast(&aBuffer)->BaseBuffer; - if (_Buffer != nullptr) + if (_Buffer) free(_Buffer); return true; } @@ -175,7 +175,7 @@ DECLARE_MKX_MASTER(KaxBlockGroup) */ uint64 GlobalTimecode() const; uint64 GlobalTimecodeScale() const { - assert(ParentTrack != nullptr); + assert(ParentTrack); return ParentTrack->GlobalTimecodeScale(); } diff --git a/matroska/KaxTracks.h b/matroska/KaxTracks.h index 3c20b9b..1edb5a0 100644 --- a/matroska/KaxTracks.h +++ b/matroska/KaxTracks.h @@ -56,7 +56,7 @@ DECLARE_MKX_MASTER(KaxTrackEntry) */ inline bool LacingEnabled() const { auto myLacing = static_cast(FindFirstElt(EBML_INFO(KaxTrackFlagLacing))); - return((myLacing == nullptr) || (static_cast(*myLacing) != 0)); + return(!myLacing || (static_cast(*myLacing) != 0)); } void SetGlobalTimecodeScale(uint64 aGlobalTimecodeScale) { diff --git a/src/KaxBlock.cpp b/src/KaxBlock.cpp index 9353513..cdf4d3d 100644 --- a/src/KaxBlock.cpp +++ b/src/KaxBlock.cpp @@ -49,7 +49,7 @@ namespace libmatroska { DataBuffer * DataBuffer::Clone() { auto ClonedData = static_cast(malloc(mySize * sizeof(binary))); - assert(ClonedData != nullptr); + assert(ClonedData); memcpy(ClonedData, myBuffer ,mySize ); auto result = new SimpleDataBuffer(ClonedData, mySize, 0); @@ -60,7 +60,7 @@ DataBuffer * DataBuffer::Clone() SimpleDataBuffer::SimpleDataBuffer(const SimpleDataBuffer & ToClone) :DataBuffer(static_cast(malloc(ToClone.mySize * sizeof(binary))), ToClone.mySize, myFreeBuffer) { - assert(myBuffer != nullptr); + assert(myBuffer); memcpy(myBuffer, ToClone.myBuffer ,mySize ); bValidValue = ToClone.bValidValue; } @@ -163,7 +163,7 @@ LacingType KaxInternalBlock::GetBestLacingType() const { filepos_t KaxInternalBlock::UpdateSize(bool /* bSaveDefault */, bool /* bForceRender */) { LacingType LacingHere; - assert(EbmlBinary::GetBuffer() == nullptr); // Data is not used for KaxInternalBlock + assert(!EbmlBinary::GetBuffer()); // Data is not used for KaxInternalBlock assert(TrackNumber < 0x4000); // no more allowed for the moment unsigned int i; @@ -249,7 +249,7 @@ filepos_t KaxBlockVirtual::UpdateSize(bool /* bSaveDefault */, bool /* bForceRen *cursor++ = TrackNumber & 0xFF; } - assert(ParentCluster != nullptr); + assert(ParentCluster); const int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode); const auto b16 = big_int16(ActualTimecode); b16.Fill(cursor); @@ -293,7 +293,7 @@ filepos_t KaxInternalBlock::RenderData(IOCallback & output, bool /* bForceRender *cursor++ = TrackNumber & 0xFF; } - assert(ParentCluster != nullptr); + assert(ParentCluster); const int16 ActualTimecode = ParentCluster->GetBlockLocalTimecode(Timecode); const auto b16 = big_int16(ActualTimecode); b16.Fill(cursor); @@ -429,7 +429,7 @@ uint64 KaxInternalBlock::ReadInternalHead(IOCallback & input) big_int16 b16; b16.Eval(cursor); - assert(ParentCluster != nullptr); + assert(ParentCluster); Timecode = ParentCluster->GetBlockGlobalTimecode(static_cast(b16)); bLocalTimecodeUsed = false; cursor += 2; @@ -721,7 +721,7 @@ filepos_t KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully) bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing) { auto & theBlock = GetChild(*this); - assert(ParentCluster != nullptr); + assert(ParentCluster); theBlock.SetParent(*ParentCluster); ParentTrack = &track; return theBlock.AddFrame(track, timecode, buffer, lacing); @@ -732,7 +732,7 @@ bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataB // assert(past_timecode < 0); auto & theBlock = GetChild(*this); - assert(ParentCluster != nullptr); + assert(ParentCluster); theBlock.SetParent(*ParentCluster); ParentTrack = &track; const bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing); @@ -751,7 +751,7 @@ bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataB // assert(forw_timecode > 0); auto & theBlock = GetChild(*this); - assert(ParentCluster != nullptr); + assert(ParentCluster); theBlock.SetParent(*ParentCluster); ParentTrack = &track; bool const bRes = theBlock.AddFrame(track, timecode, buffer, lacing); @@ -770,18 +770,18 @@ bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataB bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, const KaxBlockBlob * PastBlock, const KaxBlockBlob * ForwBlock, LacingType lacing) { auto & theBlock = GetChild(*this); - assert(ParentCluster != nullptr); + assert(ParentCluster); theBlock.SetParent(*ParentCluster); ParentTrack = &track; const bool bRes = theBlock.AddFrame(track, timecode, buffer, lacing); - if (PastBlock != nullptr) { + if (PastBlock) { auto & thePastRef = GetChild(*this); thePastRef.SetReferencedBlock(PastBlock); thePastRef.SetParentBlock(*this); } - if (ForwBlock != nullptr) { + if (ForwBlock) { auto & theFutureRef = AddNewChild(*this); theFutureRef.SetReferencedBlock(ForwBlock); theFutureRef.SetParentBlock(*this); @@ -795,7 +795,7 @@ bool KaxBlockGroup::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataB */ uint64 KaxBlockGroup::GlobalTimecode() const { - assert(ParentCluster != nullptr); // impossible otherwise + assert(ParentCluster); // impossible otherwise auto MyBlock = static_cast(this->FindElt(EBML_INFO(KaxBlock))); return MyBlock->GlobalTimecode(); } @@ -808,13 +808,13 @@ uint16 KaxBlockGroup::TrackNumber() const uint64 KaxBlockGroup::ClusterPosition() const { - assert(ParentCluster != nullptr); // impossible otherwise + assert(ParentCluster); // impossible otherwise return ParentCluster->GetPosition(); } uint64 KaxInternalBlock::ClusterPosition() const { - assert(ParentCluster != nullptr); // impossible otherwise + assert(ParentCluster); // impossible otherwise return ParentCluster->GetPosition(); } @@ -822,9 +822,9 @@ unsigned int KaxBlockGroup::ReferenceCount() const { unsigned int Result = 0; auto MyBlockAdds = static_cast(FindFirstElt(EBML_INFO(KaxReferenceBlock))); - if (MyBlockAdds != nullptr) { + if (MyBlockAdds) { Result++; - while ((MyBlockAdds = static_cast(FindNextElt(*MyBlockAdds))) != nullptr) { + while ((MyBlockAdds = static_cast(FindNextElt(*MyBlockAdds)))) { Result++; } } @@ -834,11 +834,11 @@ unsigned int KaxBlockGroup::ReferenceCount() const const KaxReferenceBlock & KaxBlockGroup::Reference(unsigned int Index) const { auto MyBlockAdds = static_cast(FindFirstElt(EBML_INFO(KaxReferenceBlock))); - assert(MyBlockAdds != nullptr); // call of a non existing reference + assert(MyBlockAdds); // call of a non existing reference while (Index != 0) { MyBlockAdds = static_cast(FindNextElt(*MyBlockAdds)); - assert(MyBlockAdds != nullptr); + assert(MyBlockAdds); Index--; } return *MyBlockAdds; @@ -854,7 +854,7 @@ void KaxInternalBlock::ReleaseFrames() { // free the allocated Frames for (int i=myBuffers.size()-1; i>=0; i--) { - if (myBuffers[i] != nullptr) { + if (myBuffers[i]) { myBuffers[i]->FreeBuffer(*myBuffers[i]); delete myBuffers[i]; myBuffers[i] = nullptr; @@ -864,7 +864,7 @@ void KaxInternalBlock::ReleaseFrames() void KaxBlockGroup::SetBlockDuration(uint64 TimeLength) { - assert(ParentTrack != nullptr); + assert(ParentTrack); const int64 scale = ParentTrack->GlobalTimecodeScale(); const auto& myDuration = static_cast(FindFirstElt(EBML_INFO(KaxBlockDuration), true)); *(static_cast(myDuration)) = TimeLength / static_cast(scale); @@ -872,12 +872,12 @@ void KaxBlockGroup::SetBlockDuration(uint64 TimeLength) bool KaxBlockGroup::GetBlockDuration(uint64 &TheTimecode) const { - auto myDuration = static_cast(FindElt(EBML_INFO(KaxBlockDuration))); - if (myDuration == nullptr) { + const auto myDuration = static_cast(FindElt(EBML_INFO(KaxBlockDuration))); + if (!myDuration) { return false; } - assert(ParentTrack != nullptr); + assert(ParentTrack); TheTimecode = static_cast(*myDuration) * ParentTrack->GlobalTimecodeScale(); return true; } @@ -973,21 +973,21 @@ KaxBlockBlob::operator KaxSimpleBlock &() bool KaxBlockBlob::AddFrameAuto(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing, const KaxBlockBlob * PastBlock, const KaxBlockBlob * ForwBlock) { bool bResult = false; - if ((SimpleBlockMode == BLOCK_BLOB_ALWAYS_SIMPLE) || (SimpleBlockMode == BLOCK_BLOB_SIMPLE_AUTO && PastBlock == nullptr && ForwBlock == nullptr)) { + if ((SimpleBlockMode == BLOCK_BLOB_ALWAYS_SIMPLE) || (SimpleBlockMode == BLOCK_BLOB_SIMPLE_AUTO && !PastBlock && !ForwBlock)) { assert(bUseSimpleBlock == true); - if (Block.simpleblock == nullptr) { + if (!Block.simpleblock) { Block.simpleblock = new KaxSimpleBlock(); Block.simpleblock->SetParent(*ParentCluster); } bResult = Block.simpleblock->AddFrame(track, timecode, buffer, lacing); - if (PastBlock == nullptr && ForwBlock == nullptr) { + if (!PastBlock && !ForwBlock) { Block.simpleblock->SetKeyframe(true); Block.simpleblock->SetDiscardable(false); } else { Block.simpleblock->SetKeyframe(false); - if ((ForwBlock == nullptr || static_cast(*ForwBlock).GlobalTimecode() <= timecode) && - (PastBlock == nullptr || static_cast(*PastBlock).GlobalTimecode() <= timecode)) + if ((!ForwBlock || static_cast(*ForwBlock).GlobalTimecode() <= timecode) && + (!PastBlock || static_cast(*PastBlock).GlobalTimecode() <= timecode)) Block.simpleblock->SetDiscardable(false); else Block.simpleblock->SetDiscardable(true); @@ -1017,14 +1017,14 @@ bool KaxBlockBlob::ReplaceSimpleByGroup() return false; if (!bUseSimpleBlock) { - if (Block.group == nullptr) { + if (!Block.group) { Block.group = new KaxBlockGroup(); } } else { - if (Block.simpleblock != nullptr) { - KaxSimpleBlock *const old_simpleblock = Block.simpleblock; + if (Block.simpleblock) { + auto old_simpleblock = Block.simpleblock; Block.group = new KaxBlockGroup(); // _TODO_ : move all the data to the blockgroup assert(false); @@ -1034,7 +1034,7 @@ bool KaxBlockBlob::ReplaceSimpleByGroup() Block.group = new KaxBlockGroup(); } } - if (ParentCluster != nullptr) + if (ParentCluster) Block.group->SetParent(*ParentCluster); bUseSimpleBlock = false; diff --git a/src/KaxBlockData.cpp b/src/KaxBlockData.cpp index e03a218..0a244ec 100644 --- a/src/KaxBlockData.cpp +++ b/src/KaxBlockData.cpp @@ -44,7 +44,7 @@ namespace libmatroska { const KaxBlockBlob & KaxReferenceBlock::RefBlock() const { - assert(RefdBlock != nullptr); + assert(RefdBlock); return *RefdBlock; } @@ -66,7 +66,7 @@ KaxReferenceBlock::~KaxReferenceBlock() void KaxReferenceBlock::FreeBlob() { - if (bOurBlob && RefdBlock!=nullptr) + if (bOurBlob && RefdBlock) delete RefdBlock; RefdBlock = nullptr; } @@ -74,8 +74,8 @@ void KaxReferenceBlock::FreeBlob() filepos_t KaxReferenceBlock::UpdateSize(bool bSaveDefault, bool bForceRender) { if (!bTimecodeSet) { - assert(RefdBlock != nullptr); - assert(ParentBlock != nullptr); + assert(RefdBlock); + assert(ParentBlock); const auto &block = static_cast(*RefdBlock); SetValue(static_cast(block.GlobalTimecode()) - static_cast(ParentBlock->GlobalTimecode()) / static_cast(ParentBlock->GlobalTimecodeScale())); @@ -85,8 +85,8 @@ filepos_t KaxReferenceBlock::UpdateSize(bool bSaveDefault, bool bForceRender) void KaxReferenceBlock::SetReferencedBlock(const KaxBlockBlob * aRefdBlock) { - assert(RefdBlock == nullptr); - assert(aRefdBlock != nullptr); + assert(!RefdBlock); + assert(aRefdBlock); FreeBlob(); RefdBlock = aRefdBlock; bOurBlob = true; diff --git a/src/KaxCluster.cpp b/src/KaxCluster.cpp index 35b5717..4b13af2 100644 --- a/src/KaxCluster.cpp +++ b/src/KaxCluster.cpp @@ -84,13 +84,13 @@ bool KaxCluster::AddFrameInternal(const KaxTrackEntry & track, uint64 timecode, } // force creation of a new block - if (currentNewBlock == nullptr || static_cast(track.TrackNumber()) != static_cast(currentNewBlock->TrackNumber()) || PastBlock != nullptr || ForwBlock != nullptr) { + if (!currentNewBlock || static_cast(track.TrackNumber()) != static_cast(currentNewBlock->TrackNumber()) || PastBlock || ForwBlock) { KaxBlockGroup & aNewBlock = GetNewBlock(); MyNewBlock = currentNewBlock = &aNewBlock; } - if (PastBlock != nullptr) { - if (ForwBlock != nullptr) { + if (PastBlock) { + if (ForwBlock) { if (currentNewBlock->AddFrame(track, timecode, buffer, *PastBlock, *ForwBlock, lacing)) { // more data are allowed in this Block return true; @@ -162,7 +162,7 @@ filepos_t KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bS // the track wasn't found in this cluster if (track == ElementList.end()) { auto SilentTracks = static_cast(this->FindFirstElt(EBML_INFO(KaxClusterSilentTracks))); - assert(SilentTracks != nullptr); // the flag bSilentTracksUsed should be set when creating the Cluster + assert(SilentTracks); // the flag bSilentTracksUsed should be set when creating the Cluster auto trackelt = static_cast(SilentTracks->AddNewElt(EBML_INFO(KaxClusterSilentTrackNumber))); *static_cast(trackelt) = tracknum; } @@ -202,7 +202,7 @@ filepos_t KaxCluster::Render(IOCallback & output, KaxCues & CueToUpdate, bool bS // the track wasn't found in this cluster if (Index == ListSize()) { auto SilentTracks = static_cast(this->FindFirstElt(EBML_INFO(KaxClusterSilentTracks))); - assert(SilentTracks != nullptr); // the flag bSilentTracksUsed should be set when creating the Cluster + assert(SilentTracks); // the flag bSilentTracksUsed should be set when creating the Cluster auto trackelt = static_cast(SilentTracks->AddNewElt(EBML_INFO(KaxClusterSilentTrackNumber))); *static_cast(trackelt) = tracknum; } @@ -277,7 +277,7 @@ void KaxCluster::ReleaseFrames() uint64 KaxCluster::GetPosition() const { - assert(ParentSegment != nullptr); + assert(ParentSegment); return ParentSegment->GetRelativePosition(*this); } diff --git a/src/KaxCues.cpp b/src/KaxCues.cpp index 862341b..5151e33 100644 --- a/src/KaxCues.cpp +++ b/src/KaxCues.cpp @@ -121,7 +121,7 @@ const KaxCuePoint * KaxCues::GetTimecodePoint(uint64 aTimecode) const auto tmp = static_cast(e); // check the tile auto aTime = static_cast(tmp->FindFirstElt(EBML_INFO(KaxCueTime))); - if (aTime != nullptr) { + if (aTime) { auto _Time = static_cast(*aTime); if (_Time > aPrevTime && _Time < TimecodeToLocate) { aPrevTime = _Time; @@ -139,12 +139,12 @@ const KaxCuePoint * KaxCues::GetTimecodePoint(uint64 aTimecode) const uint64 KaxCues::GetTimecodePosition(uint64 aTimecode) const { - const KaxCuePoint * const aPoint = GetTimecodePoint(aTimecode); - if (aPoint == nullptr) + const auto aPoint = GetTimecodePoint(aTimecode); + if (!aPoint) return 0; - const KaxCueTrackPositions * const aTrack = aPoint->GetSeekPosition(); - if (aTrack == nullptr) + const auto aTrack = aPoint->GetSeekPosition(); + if (!aTrack) return 0; return aTrack->ClusterPosition(); diff --git a/src/KaxCuesData.cpp b/src/KaxCuesData.cpp index 13cef98..2cb252b 100644 --- a/src/KaxCuesData.cpp +++ b/src/KaxCuesData.cpp @@ -69,7 +69,7 @@ void KaxCuePoint::PositionSet(const KaxBlockGroup & BlockReference, uint64 Globa } auto CodecState = static_cast(BlockReference.FindFirstElt(EBML_INFO(KaxCodecState))); - if (CodecState != nullptr) { + if (CodecState) { auto &CueCodecState = AddNewChild(NewPositions); *static_cast(&CueCodecState) = BlockReference.GetParentCluster()->GetParentSegment()->GetRelativePosition(CodecState->GetElementPosition()); } @@ -118,9 +118,9 @@ void KaxCuePoint::PositionSet(const KaxInternalBlock & BlockReference, const Kax } #endif // MATROSKA_VERSION - if (BlockGroup != nullptr) { + if (BlockGroup) { const auto CodecState = static_cast(BlockGroup->FindFirstElt(EBML_INFO(KaxCodecState))); - if (CodecState != nullptr) { + if (CodecState) { auto &CueCodecState = AddNewChild(NewPositions); *static_cast(&CueCodecState) = BlockGroup->GetParentCluster()->GetParentSegment()->GetRelativePosition(CodecState->GetElementPosition()); } @@ -161,11 +161,11 @@ bool KaxCuePoint::IsSmallerThan(const EbmlElement * Cmp) const // compare timecode auto TimeCodeA = static_cast(FindElt(EBML_INFO(KaxCueTime))); - if (TimeCodeA == nullptr) + if (!TimeCodeA) return false; auto TimeCodeB = static_cast(theCmp->FindElt(EBML_INFO(KaxCueTime))); - if (TimeCodeB == nullptr) + if (!TimeCodeB) return false; if (TimeCodeA->IsSmallerThan(TimeCodeB)) @@ -175,12 +175,12 @@ bool KaxCuePoint::IsSmallerThan(const EbmlElement * Cmp) const return false; // compare tracks (timecodes are equal) - auto TrackA = static_cast(FindElt(EBML_INFO(KaxCueTrack))); - if (TrackA == nullptr) + const auto TrackA = static_cast(FindElt(EBML_INFO(KaxCueTrack))); + if (!TrackA) return false; - auto TrackB = static_cast(theCmp->FindElt(EBML_INFO(KaxCueTrack))); - if (TrackB == nullptr) + const auto TrackB = static_cast(theCmp->FindElt(EBML_INFO(KaxCueTrack))); + if (!TrackB) return false; if (TrackA->IsSmallerThan(TrackB)) @@ -194,8 +194,8 @@ bool KaxCuePoint::IsSmallerThan(const EbmlElement * Cmp) const bool KaxCuePoint::Timecode(uint64 & aTimecode, uint64 GlobalTimecodeScale) const { - auto aTime = static_cast(FindFirstElt(EBML_INFO(KaxCueTime))); - if (aTime == nullptr) + const auto aTime = static_cast(FindFirstElt(EBML_INFO(KaxCueTime))); + if (!aTime) return false; aTimecode = static_cast(*aTime) * GlobalTimecodeScale; return true; @@ -210,9 +210,9 @@ const KaxCueTrackPositions * KaxCuePoint::GetSeekPosition() const uint64 aPosition = EBML_PRETTYLONGINT(0xFFFFFFFFFFFFFFF); // find the position of the "earlier" Cluster auto aPoss = static_cast(FindFirstElt(EBML_INFO(KaxCueTrackPositions))); - while (aPoss != nullptr) { + while (aPoss) { auto aPos = static_cast(aPoss->FindFirstElt(EBML_INFO(KaxCueClusterPosition))); - if (aPos != nullptr && static_cast(*aPos) < aPosition) { + if (aPos && static_cast(*aPos) < aPosition) { aPosition = static_cast(*aPos); result = aPoss; } @@ -224,8 +224,8 @@ const KaxCueTrackPositions * KaxCuePoint::GetSeekPosition() const uint64 KaxCueTrackPositions::ClusterPosition() const { - auto aPos = static_cast(FindFirstElt(EBML_INFO(KaxCueClusterPosition))); - if (aPos == nullptr) + const auto aPos = static_cast(FindFirstElt(EBML_INFO(KaxCueClusterPosition))); + if (!aPos) return 0; return static_cast(*aPos); @@ -233,8 +233,8 @@ uint64 KaxCueTrackPositions::ClusterPosition() const uint16 KaxCueTrackPositions::TrackNumber() const { - auto aTrack = static_cast(FindFirstElt(EBML_INFO(KaxCueTrack))); - if (aTrack == nullptr) + const auto aTrack = static_cast(FindFirstElt(EBML_INFO(KaxCueTrack))); + if (!aTrack) return 0; return static_cast(*aTrack); diff --git a/src/KaxSeekHead.cpp b/src/KaxSeekHead.cpp index 304cad8..1421205 100644 --- a/src/KaxSeekHead.cpp +++ b/src/KaxSeekHead.cpp @@ -67,7 +67,7 @@ KaxSeek * KaxSeekHead::FindFirstOf(const EbmlCallbacks & Callbacks) const { // parse all the Entries and find the first to match the type auto aElt = static_cast(FindFirstElt(EBML_INFO(KaxSeek))); - while (aElt != nullptr) { + while (aElt) { auto it = std::find_if(aElt->begin(), aElt->end(), [&](auto Elt) { return (EbmlId(*Elt) == EBML_ID(KaxSeekID)); }); if (it != aElt->end()) { @@ -101,7 +101,7 @@ KaxSeek * KaxSeekHead::FindNextOf(const KaxSeek &aPrev) const int64 KaxSeek::Location() const { auto aPos = static_cast(FindFirstElt(EBML_INFO(KaxSeekPosition))); - if (aPos == nullptr) + if (!aPos) return 0; return static_cast(*aPos); } @@ -109,7 +109,7 @@ int64 KaxSeek::Location() const bool KaxSeek::IsEbmlId(const EbmlId & aId) const { auto _Id = static_cast(FindFirstElt(EBML_INFO(KaxSeekID))); - if (_Id == nullptr) + if (!_Id) return false; const auto aEbmlId = EbmlId(_Id->GetBuffer(), _Id->GetSize()); return (aId == aEbmlId); @@ -118,14 +118,14 @@ bool KaxSeek::IsEbmlId(const EbmlId & aId) const bool KaxSeek::IsEbmlId(const KaxSeek & aPoint) const { auto _IdA = static_cast(FindFirstElt(EBML_INFO(KaxSeekID))); - if (_IdA == nullptr) + if (!_IdA) return false; auto _IdB = static_cast(aPoint.FindFirstElt(EBML_INFO(KaxSeekID))); - if (_IdB == nullptr) + if (!_IdB) return false; const auto aEbmlIdA = EbmlId(_IdA->GetBuffer(), _IdA->GetSize()); const auto aEbmlIdB = EbmlId(_IdB->GetBuffer(), _IdB->GetSize()); - return (aEbmlIdA == aEbmlIdB); + return aEbmlIdA == aEbmlIdB; } } // namespace libmatroska