Foundation Classes - Modernize NCollection_SparseArrayBase memory handling and style (#804)

- Replace malloc/calloc/free with Standard::AllocateOptimal/Standard::Free for OCCT-consistent memory management
- Modernize constructor declarations and use nullptr instead of 0 for null pointers
- Replace custom swap implementation with std::swap and add noexcept specifications
This commit is contained in:
Pasukhin Dmitry
2025-11-04 10:55:54 +00:00
committed by GitHub
parent f0f1578853
commit f923370c82
3 changed files with 55 additions and 38 deletions
@@ -164,7 +164,7 @@ public:
// Methods for descendant
//! Empty constructor
Standard_EXPORT Iterator(const NCollection_SparseArrayBase* theArray = 0);
Standard_EXPORT Iterator(const NCollection_SparseArrayBase* theArray = nullptr);
//! Initialize by the specified array
Standard_EXPORT void init(const NCollection_SparseArrayBase* theArray);
@@ -182,9 +182,9 @@ public:
friend class Iterator;
private:
// Copy constructor and assignment operator are private thus not accessible
NCollection_SparseArrayBase(const NCollection_SparseArrayBase&);
void operator=(const NCollection_SparseArrayBase&);
// Copy constructor and assignment operator are deleted
NCollection_SparseArrayBase(const NCollection_SparseArrayBase&) = delete;
NCollection_SparseArrayBase& operator=(const NCollection_SparseArrayBase&) = delete;
protected:
// Object life
@@ -195,7 +195,7 @@ protected:
myBlockSize(theBlockSize),
myNbBlocks(0),
mySize(0),
myData(0)
myData(nullptr)
{
}
@@ -238,7 +238,7 @@ protected:
//! Exchange contents of theOther and this;
//! assumes that this and theOther have exactly the same type of arguments
Standard_EXPORT void exchange(NCollection_SparseArrayBase& theOther);
Standard_EXPORT void exchange(NCollection_SparseArrayBase& theOther) noexcept;
protected:
// Methods to be provided by descendant