Skip to content

Commit

Permalink
remove EbmlElement locking
Browse files Browse the repository at this point in the history
This was designed to be able to keep a pointer alive after its parent master
element is destroyed. But it's not used anywhere and a C++ refcounting should be used for that.
  • Loading branch information
robUx4 committed Dec 18, 2023
1 parent ca27cb0 commit 96156fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
4 changes: 0 additions & 4 deletions ebml/EbmlElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,6 @@ class EBML_DLL_API EbmlElement {
virtual filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) = 0;
virtual void Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt = false, ScopeMode ReadFully = SCOPE_ALL_DATA);

bool IsLocked() const {return bLocked;}
void Lock(bool bLock = true) { bLocked = bLock;}

/*!
\brief default comparison for elements that can't be compared
*/
Expand Down Expand Up @@ -427,7 +424,6 @@ class EBML_DLL_API EbmlElement {
std::uint64_t SizePosition{0};
bool bValueIsSet;
bool DefaultIsSet{false};
bool bLocked{false};
};

} // namespace libebml
Expand Down
10 changes: 2 additions & 8 deletions src/EbmlMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ EbmlMaster::EbmlMaster(const EbmlMaster & ElementToClone)

EbmlMaster::~EbmlMaster()
{
assert(!IsLocked()); // you're trying to delete a locked element !!!

for (auto Element : ElementList) {
if (!Element->IsLocked()) {
delete Element;
}
delete Element;
}
}

Expand Down Expand Up @@ -375,9 +371,7 @@ void EbmlMaster::Read(EbmlStream & inDataStream, const EbmlSemanticContext & sCo
EbmlElement * ElementLevelA;
// remove all existing elements, including the mandatory ones...
for (auto Element : ElementList) {
if (!Element->IsLocked()) {
delete Element;
}
delete Element;
}
ElementList.clear();
std::uint64_t MaxSizeToRead;
Expand Down

0 comments on commit 96156fd

Please sign in to comment.