1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0025616: Avoid Classes using "new" to allocate Instances but not defining a copy Constructor

The empty copy constructor, assignemnts operator, default constructors added to the following classes:
The following classes use “new” function without Handles:
- Select3D_PointData
- BSB_T3Bits
- IntPatch_InfoPD
- LDOM_StringElem
- BinomAllocator
- ProjLib_OnSurface
- Standard_MMgrFactory

Useless declaration of default constructor have been deleted.
This commit is contained in:
azn
2015-01-15 14:41:27 +03:00
committed by bugmaster
parent c8be748cd4
commit 6a38ff486c
8 changed files with 96 additions and 57 deletions

View File

@@ -14,33 +14,22 @@
// commercial license or contractual agreement.
#include <LDOM_OSStream.hxx>
#include <NCollection_DefineAlloc.hxx>
#include <NCollection_IncAllocator.hxx>
#include <string.h>
#include <Standard.hxx>
#include <Standard_Integer.hxx>
// One element of sequence
/* Can only be allocated by the allocator and assumes it is IncAllocator, so
no destructor is required.
*/
class LDOM_StringElem
//=======================================================================
//function : LDOM_StringElem()
//purpose : Constructor
//=======================================================================
LDOM_SBuffer::LDOM_StringElem::LDOM_StringElem
( const int theLength, const Handle_NCollection_BaseAllocator& theAlloc )
: buf (reinterpret_cast<char*>(theAlloc->Allocate (theLength))),
len (0),
next(0)
{
char* buf; // pointer on data string
int len; // quantity of really written data
LDOM_StringElem* next; // pointer on the next element of a sequence
DEFINE_NCOLLECTION_ALLOC
LDOM_StringElem (int aLen, const Handle_NCollection_BaseAllocator& theAlloc) :
buf (reinterpret_cast<char*> (theAlloc->Allocate (aLen))),
len (0),
next (0)
{
}
friend class LDOM_SBuffer;
};
}
//=======================================================================
//function : LDOM_SBuffer()

View File

@@ -32,6 +32,7 @@
// and current element of sequence,
// also it has methods for the sequence management.
#include <NCollection_DefineAlloc.hxx>
#include <NCollection_BaseAllocator.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Boolean.hxx>
@@ -39,11 +40,28 @@
#include <stdlib.h>
#include <stdio.h> /* EOF */
class LDOM_StringElem; // defined in cxx file
class LDOM_SBuffer : public streambuf
{
public:
// One element of sequence.
// Can only be allocated by the allocator and assumes
// it is IncAllocator, so destructor isn't required.
struct LDOM_StringElem
{
char* buf; //!< pointer on data string
int len; //!< quantity of really written data
LDOM_StringElem* next; //!< pointer on the next element of a sequence
DEFINE_NCOLLECTION_ALLOC
LDOM_StringElem(const int, const Handle_NCollection_BaseAllocator&);
~LDOM_StringElem();
private:
LDOM_StringElem (const LDOM_StringElem&);
LDOM_StringElem& operator= (const LDOM_StringElem&);
};
public:
Standard_EXPORT LDOM_SBuffer (const Standard_Integer theMaxBuf);
// Constructor. Sets a default value for the
// length of each sequence element.
@@ -74,8 +92,8 @@ class LDOM_SBuffer : public streambuf
Standard_EXPORT ~LDOM_SBuffer ();
// Destructor
private:
private:
Standard_Integer myMaxBuf; // default length of one element
Standard_Integer myLength; // full length of contained data
LDOM_StringElem* myFirstString; // the head of the sequence