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 ffd4b3f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
6 changes: 1 addition & 5 deletions ebml/EbmlElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class EBML_DLL_API EbmlSemanticContext {
class EBML_DLL_API EbmlElement {
public:
explicit EbmlElement(std::uint64_t aDefaultSize, bool bValueSet = false);
virtual ~EbmlElement();
virtual ~EbmlElement() = default;
EbmlElement& operator=(const EbmlElement&) = delete;

/// Set the minimum length that will be used to write the element size (-1 = optimal)
Expand Down 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
5 changes: 0 additions & 5 deletions src/EbmlElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ EbmlElement::EbmlElement(std::uint64_t aDefaultSize, bool bValueSet)
Size = DefaultSize;
}

EbmlElement::~EbmlElement()
{
assert(!bLocked);
}

/*!
\todo this method is deprecated and should be called FindThisID
\todo replace the new RawElement with the appropriate class (when known)
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 ffd4b3f

Please sign in to comment.