]> granicus.if.org Git - libmatroska/commitdiff
nullptr + const changes
authorRosen Penev <rosenp@gmail.com>
Sun, 2 Oct 2022 20:49:09 +0000 (13:49 -0700)
committerRosen Penev <rosenp@gmail.com>
Sun, 2 Oct 2022 21:05:04 +0000 (14:05 -0700)
Remove nullptr comparison. Just use bool.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
matroska/KaxBlock.h
matroska/KaxTracks.h
src/KaxBlock.cpp
src/KaxBlockData.cpp
src/KaxCluster.cpp
src/KaxCues.cpp
src/KaxCuesData.cpp
src/KaxSeekHead.cpp

index 14d7a55a4ee218f1fe47738e98a0b73229821f79..9e22829ac74e2ad1a23bcd6b1a95aca6eafaff82 100644 (file)
@@ -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<const SimpleDataBuffer*>(&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();
     }
 
index 3c20b9ba87631ebe54fb4d45cd177a740f373150..1edb5a0e51be86ae7e1d5c6b07a513c64038106b 100644 (file)
@@ -56,7 +56,7 @@ DECLARE_MKX_MASTER(KaxTrackEntry)
     */
     inline bool LacingEnabled() const {
       auto myLacing = static_cast<KaxTrackFlagLacing *>(FindFirstElt(EBML_INFO(KaxTrackFlagLacing)));
-      return((myLacing == nullptr) || (static_cast<uint8>(*myLacing) != 0));
+      return(!myLacing || (static_cast<uint8>(*myLacing) != 0));
     }
 
     void SetGlobalTimecodeScale(uint64 aGlobalTimecodeScale) {
index 9353513165518c8b81267e34f44b4a0af037b3ba..cdf4d3d87b387f5603f23a57241ec19b0782d953 100644 (file)
@@ -49,7 +49,7 @@ namespace libmatroska {
 DataBuffer * DataBuffer::Clone()
 {
   auto ClonedData = static_cast<binary *>(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<binary *>(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<int16>(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<KaxBlock>(*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<KaxBlock>(*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<KaxBlock>(*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<KaxBlock>(*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<KaxReferenceBlock>(*this);
     thePastRef.SetReferencedBlock(PastBlock);
     thePastRef.SetParentBlock(*this);
   }
 
-  if (ForwBlock != nullptr) {
+  if (ForwBlock) {
     auto & theFutureRef = AddNewChild<KaxReferenceBlock>(*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<KaxBlock *>(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<KaxReferenceBlock *>(FindFirstElt(EBML_INFO(KaxReferenceBlock)));
-  if (MyBlockAdds != nullptr) {
+  if (MyBlockAdds) {
     Result++;
-    while ((MyBlockAdds = static_cast<KaxReferenceBlock *>(FindNextElt(*MyBlockAdds))) != nullptr) {
+    while ((MyBlockAdds = static_cast<KaxReferenceBlock *>(FindNextElt(*MyBlockAdds)))) {
       Result++;
     }
   }
@@ -834,11 +834,11 @@ unsigned int KaxBlockGroup::ReferenceCount() const
 const KaxReferenceBlock & KaxBlockGroup::Reference(unsigned int Index) const
 {
   auto MyBlockAdds = static_cast<KaxReferenceBlock *>(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<KaxReferenceBlock *>(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<KaxBlockDuration *>(FindFirstElt(EBML_INFO(KaxBlockDuration), true));
   *(static_cast<EbmlUInteger *>(myDuration)) = TimeLength / static_cast<uint64>(scale);
@@ -872,12 +872,12 @@ void KaxBlockGroup::SetBlockDuration(uint64 TimeLength)
 
 bool KaxBlockGroup::GetBlockDuration(uint64 &TheTimecode) const
 {
-  auto myDuration = static_cast<KaxBlockDuration *>(FindElt(EBML_INFO(KaxBlockDuration)));
-  if (myDuration == nullptr) {
+  const auto myDuration = static_cast<KaxBlockDuration *>(FindElt(EBML_INFO(KaxBlockDuration)));
+  if (!myDuration) {
     return false;
   }
 
-  assert(ParentTrack != nullptr);
+  assert(ParentTrack);
   TheTimecode = static_cast<uint64>(*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<const KaxInternalBlock &>(*ForwBlock).GlobalTimecode() <= timecode) &&
-          (PastBlock == nullptr || static_cast<const KaxInternalBlock &>(*PastBlock).GlobalTimecode() <= timecode))
+      if ((!ForwBlock || static_cast<const KaxInternalBlock &>(*ForwBlock).GlobalTimecode() <= timecode) &&
+          (!PastBlock || static_cast<const KaxInternalBlock &>(*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;
index e03a218f151dbf80321dd37b65a36d539bb13a5d..0a244ecbc715cd0d687f7030059fb3c89a339f5c 100644 (file)
@@ -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<const KaxInternalBlock&>(*RefdBlock);
     SetValue(static_cast<int64>(block.GlobalTimecode()) - static_cast<int64>(ParentBlock->GlobalTimecode()) / static_cast<int64>(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;
index 35b57171f9daa481a73c155e92fd57722ef1c511..4b13af22f7739c097ea06fcbc618bbb6b8cde1fb 100644 (file)
@@ -84,13 +84,13 @@ bool KaxCluster::AddFrameInternal(const KaxTrackEntry & track, uint64 timecode,
   }
 
   // force creation of a new block
-  if (currentNewBlock == nullptr || static_cast<uint32>(track.TrackNumber()) != static_cast<uint32>(currentNewBlock->TrackNumber()) || PastBlock != nullptr || ForwBlock != nullptr) {
+  if (!currentNewBlock || static_cast<uint32>(track.TrackNumber()) != static_cast<uint32>(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<KaxClusterSilentTracks *>(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<KaxClusterSilentTrackNumber *>(SilentTracks->AddNewElt(EBML_INFO(KaxClusterSilentTrackNumber)));
             *static_cast<EbmlUInteger *>(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<KaxClusterSilentTracks *>(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<KaxClusterSilentTrackNumber *>(SilentTracks->AddNewElt(EBML_INFO(KaxClusterSilentTrackNumber)));
             *static_cast<EbmlUInteger *>(trackelt) = tracknum;
           }
@@ -277,7 +277,7 @@ void KaxCluster::ReleaseFrames()
 
 uint64 KaxCluster::GetPosition() const
 {
-  assert(ParentSegment != nullptr);
+  assert(ParentSegment);
   return ParentSegment->GetRelativePosition(*this);
 }
 
index 862341b050281ac60f1114ec1a468f6ece222d04..5151e33e17b01017c6c8946490ba91c3e64ee8e6 100644 (file)
@@ -121,7 +121,7 @@ const KaxCuePoint * KaxCues::GetTimecodePoint(uint64 aTimecode) const
       auto tmp = static_cast<const KaxCuePoint *>(e);
       // check the tile
       auto aTime = static_cast<const KaxCueTime *>(tmp->FindFirstElt(EBML_INFO(KaxCueTime)));
-      if (aTime != nullptr) {
+      if (aTime) {
         auto _Time = static_cast<uint64>(*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();
index 13cef9831f9732136770fd619a30a2cddaa5493e..2cb252bb4623cc068c5b9fb96d829ed78479054a 100644 (file)
@@ -69,7 +69,7 @@ void KaxCuePoint::PositionSet(const KaxBlockGroup & BlockReference, uint64 Globa
   }
 
   auto CodecState = static_cast<KaxCodecState *>(BlockReference.FindFirstElt(EBML_INFO(KaxCodecState)));
-  if (CodecState != nullptr) {
+  if (CodecState) {
     auto &CueCodecState = AddNewChild<KaxCueCodecState>(NewPositions);
     *static_cast<EbmlUInteger*>(&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<const KaxCodecState *>(BlockGroup->FindFirstElt(EBML_INFO(KaxCodecState)));
-    if (CodecState != nullptr) {
+    if (CodecState) {
       auto &CueCodecState = AddNewChild<KaxCueCodecState>(NewPositions);
       *static_cast<EbmlUInteger*>(&CueCodecState) = BlockGroup->GetParentCluster()->GetParentSegment()->GetRelativePosition(CodecState->GetElementPosition());
     }
@@ -161,11 +161,11 @@ bool KaxCuePoint::IsSmallerThan(const EbmlElement * Cmp) const
 
   // compare timecode
   auto TimeCodeA = static_cast<const KaxCueTime *>(FindElt(EBML_INFO(KaxCueTime)));
-  if (TimeCodeA == nullptr)
+  if (!TimeCodeA)
     return false;
 
   auto TimeCodeB = static_cast<const KaxCueTime *>(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<const KaxCueTrack *>(FindElt(EBML_INFO(KaxCueTrack)));
-  if (TrackA == nullptr)
+  const auto TrackA = static_cast<const KaxCueTrack *>(FindElt(EBML_INFO(KaxCueTrack)));
+  if (!TrackA)
     return false;
 
-  auto TrackB = static_cast<const KaxCueTrack *>(theCmp->FindElt(EBML_INFO(KaxCueTrack)));
-  if (TrackB == nullptr)
+  const auto TrackB = static_cast<const KaxCueTrack *>(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<const KaxCueTime *>(FindFirstElt(EBML_INFO(KaxCueTime)));
-  if (aTime == nullptr)
+  const auto aTime = static_cast<const KaxCueTime *>(FindFirstElt(EBML_INFO(KaxCueTime)));
+  if (!aTime)
     return false;
   aTimecode = static_cast<uint64>(*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<const KaxCueTrackPositions *>(FindFirstElt(EBML_INFO(KaxCueTrackPositions)));
-  while (aPoss != nullptr) {
+  while (aPoss) {
     auto aPos = static_cast<const KaxCueClusterPosition *>(aPoss->FindFirstElt(EBML_INFO(KaxCueClusterPosition)));
-    if (aPos != nullptr && static_cast<uint64>(*aPos) < aPosition) {
+    if (aPos && static_cast<uint64>(*aPos) < aPosition) {
       aPosition = static_cast<uint64>(*aPos);
       result = aPoss;
     }
@@ -224,8 +224,8 @@ const KaxCueTrackPositions * KaxCuePoint::GetSeekPosition() const
 
 uint64 KaxCueTrackPositions::ClusterPosition() const
 {
-  auto aPos = static_cast<const KaxCueClusterPosition *>(FindFirstElt(EBML_INFO(KaxCueClusterPosition)));
-  if (aPos == nullptr)
+  const auto aPos = static_cast<const KaxCueClusterPosition *>(FindFirstElt(EBML_INFO(KaxCueClusterPosition)));
+  if (!aPos)
     return 0;
 
   return static_cast<uint64>(*aPos);
@@ -233,8 +233,8 @@ uint64 KaxCueTrackPositions::ClusterPosition() const
 
 uint16 KaxCueTrackPositions::TrackNumber() const
 {
-  auto aTrack = static_cast<const KaxCueTrack *>(FindFirstElt(EBML_INFO(KaxCueTrack)));
-  if (aTrack == nullptr)
+  const auto aTrack = static_cast<const KaxCueTrack *>(FindFirstElt(EBML_INFO(KaxCueTrack)));
+  if (!aTrack)
     return 0;
 
   return static_cast<uint16>(*aTrack);
index 304cad888f17906a59865f5116d33b27b891042e..1421205696d18d93df143a0684d8a8d249149151 100644 (file)
@@ -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<KaxSeek *>(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<KaxSeekPosition*>(FindFirstElt(EBML_INFO(KaxSeekPosition)));
-  if (aPos == nullptr)
+  if (!aPos)
     return 0;
   return static_cast<uint64>(*aPos);
 }
@@ -109,7 +109,7 @@ int64 KaxSeek::Location() const
 bool KaxSeek::IsEbmlId(const EbmlId & aId) const
 {
   auto _Id = static_cast<KaxSeekID*>(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<KaxSeekID*>(FindFirstElt(EBML_INFO(KaxSeekID)));
-  if (_IdA == nullptr)
+  if (!_IdA)
     return false;
   auto _IdB = static_cast<KaxSeekID*>(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