Method Standard::Free() is converted to template, so that pointer is nullified using its proper type.
Unnecessary type cases in calls to Standard::Free(), Standard::Reallocate(), and NCollection_BaseAllocator::Free() eliminated throughout OCCT code.
static
int mcrfree_(integer *ibyte,
- void* *iadr,
+ intptr_t iadr,
integer *ier);
static
int mcrgetv_(integer *sz,
- void* *iad,
+ intptr_t *iad,
integer *ier);
static
}
} else {
/* DE-ALLOCATION SYSTEM */
- mcrfree_(&ibyte, reinterpret_cast<void**> (&iaddr), &ier);
+ mcrfree_(&ibyte, iaddr, &ier);
if (ier != 0) {
goto L9002;
}
//purpose :
//=======================================================================
int mcrfree_(integer *,//ibyte,
- void* *iadr,
+ intptr_t iadr,
integer *ier)
{
*ier=0;
- Standard::Free(*iadr);
- //Standard::Free always nullifies address, so check becomes incorrect
- //if ( !*iadr ) *ier = 1;
+ Standard::Free((void*)iadr);
return 0;
}
//purpose :
//=======================================================================
int mcrgetv_(integer *sz,
- void* *iad,
+ intptr_t *iad,
integer *ier)
{
*ier = 0;
- *iad = Standard::Allocate(*sz);
+ *iad = (intptr_t)Standard::Allocate(*sz);
if ( !*iad ) *ier = 1;
return 0;
}
/* ELSE */
/* ALLOCATION SYSTEME */
ksys = heap_allocation;
- mcrgetv_(&ibyte, reinterpret_cast<void**> (&iaddr), &ier);
+ mcrgetv_(&ibyte, &iaddr, &ier);
if (ier != 0) {
goto L9003;
}
for (i=0; i<mySize; ++i) {
myData[i].~Type();
}
- myAllocator->Free((Standard_Address&)myData);
+ myAllocator->Free(myData);
//
myData=NULL;
mySize=0;
while(pBlock) {
pNext=pBlock->Next();
//
- //pBlock->~BOPCol_MemBlock<Type> ();
pBlock->~BOPCol_XMemBlock();
- //pBlock->Clear();
- myAllocator->Free((Standard_Address&)pBlock);
+ myAllocator->Free(pBlock);
//
pBlock=pNext;
}
myNbIds=0;
mySum=0;
if (myPtr) {
- myAllocator->Free((Standard_Address)myPtr);
+ myAllocator->Free(myPtr);
myPtr=NULL;
}
}
for (i=0; i<aNb; ++i) {
pPaves[i].~BOPDS_Pave();
}
- myAllocator->Free((Standard_Address&)pPaves);
+ myAllocator->Free(pPaves);
}
//=======================================================================
for (i=0; i<aNb; ++i) {
pShapes[i].~TopoDS_Shape();
}
- myAllocator->Free((Standard_Address&)pShapes);
+ myAllocator->Free(pShapes);
}
//=======================================================================
//function : AddEdges
for (i=0; i<aNb; ++i) {
pShapes[i].~TopoDS_Shape();
}
- myAllocator->Free((Standard_Address&)pShapes);
+ myAllocator->Free(pShapes);
}
//=======================================================================
//function : IsEqual
ptrtmp->DBC_VArrayTNode::~DBC_VArrayTNode();
ptrtmp++;
}
- Standard::Free((Standard_Address&)myData);
+ Standard::Free(myData);
} else {
for(i = 0; i < NewSize; i++) {
ptrtmp = new((Standard_Address)ptrtmp) DBC_VArrayTNode();
ptrtmp->DBC_VArrayTNode::~DBC_VArrayTNode();
ptrtmp++;
}
- Standard::Free((Standard_Address&)myData);
+ Standard::Free(myData);
myData = 0L;
}
#endif
if (!fread(c,size,1,myStream)) Storage_StreamWriteError::Raise();
c[size] = '\0';
aString = c;
- Standard::Free((Standard_Address&)c);
+ Standard::Free(c);
}
else {
aString.Clear();
c[i] = InverseExtChar (c[i]);
#endif
aString = c;
- Standard::Free((Standard_Address&)c);
+ Standard::Free(c);
}
else {
aString.Clear();
{
if( myPrimitiveArray ) {
if( myPrimitiveArray->vertices ){
- Standard::Free( (Standard_Address&)myPrimitiveArray->vertices );
+ Standard::Free (myPrimitiveArray->vertices);
myPrimitiveArray->vertices = 0;
}
if( myPrimitiveArray->vnormals ){
- Standard::Free( (Standard_Address&)myPrimitiveArray->vnormals );
+ Standard::Free (myPrimitiveArray->vnormals);
myPrimitiveArray->vnormals = 0;
}
if( myPrimitiveArray->vcolours ){
- Standard::Free( (Standard_Address&)myPrimitiveArray->vcolours );
+ Standard::Free (myPrimitiveArray->vcolours);
myPrimitiveArray->vcolours = 0;
}
if( myPrimitiveArray->vtexels ){
- Standard::Free( (Standard_Address&)myPrimitiveArray->vtexels );
+ Standard::Free (myPrimitiveArray->vtexels);
myPrimitiveArray->vtexels = 0;
}
if( myPrimitiveArray->fcolours ){
- Standard::Free( (Standard_Address&)myPrimitiveArray->fcolours );
+ Standard::Free (myPrimitiveArray->fcolours);
myPrimitiveArray->fcolours = 0;
}
if( myPrimitiveArray->bounds ){
- Standard::Free( (Standard_Address&)myPrimitiveArray->bounds );
+ Standard::Free (myPrimitiveArray->bounds);
myPrimitiveArray->bounds = 0;
}
if( myPrimitiveArray->edges ){
- Standard::Free( (Standard_Address&)myPrimitiveArray->edges );
+ Standard::Free (myPrimitiveArray->edges);
myPrimitiveArray->edges = 0;
}
if( myPrimitiveArray->edge_vis ){
- Standard::Free( (Standard_Address&)myPrimitiveArray->edge_vis );
+ Standard::Free (myPrimitiveArray->edge_vis);
myPrimitiveArray->edge_vis = 0;
}
- Standard::Free( (Standard_Address&)myPrimitiveArray );
+ Standard::Free (myPrimitiveArray);
#if TRACE > 0
cout << " Graphic3d_ArrayOfPrimitives::Destroy()" << endl;
#endif
while(edges[ivert] != NULL) {
cedge = edges[ivert];
edges[ivert] = cedge->next;
- Standard::Free((void*&)cedge);
+ Standard::Free(cedge);
}
}
- Standard::Free((void*&)edges);
+ Standard::Free(edges);
}
{
NBTRIANGLES = 0;
current_stript.t = 0;
- Standard::Free((void*&)trianglesptr);
+ Standard::Free(trianglesptr);
return;
}
{
cedge = edges[ivert];
edges[ivert] = cedge->next;
- Standard::Free((void*&)cedge);
+ Standard::Free(cedge);
}
}
- Standard::Free((void*&)edges);
+ Standard::Free(edges);
}
{
NBQUAD = 0;
current_stripq.q = 0;
- Standard::Free((void*&)quadranglesptr);
+ Standard::Free(quadranglesptr);
return;
}
/* Now search the best strip from this quadrangle
void NCollection_BaseAllocator::Free(void *anAddress)
{
- if (anAddress) Standard::Free((Standard_Address&)anAddress);
+ if (anAddress) Standard::Free(anAddress);
}
//=======================================================================
void Deallocate()
{
if (myPtr != myBuffer)
- Standard::Free (*(Standard_Address*)&myPtr);
+ Standard::Free (myPtr);
}
protected:
//! Release string buffer and nullify the pointer.
static void strFree (Type*& thePtr)
{
- void* aPtr = thePtr;
- Standard::Free (aPtr);
- thePtr = NULL;
+ Standard::Free (thePtr);
}
//! Provides bytes interface to avoid incorrect pointer arithmetics.
// =======================================================================
void OpenGl_PrimitiveArray::clearMemoryOwn() const
{
- Standard::Free ((Standard_Address& )myPArray->edges);
- Standard::Free ((Standard_Address& )myPArray->vertices);
- Standard::Free ((Standard_Address& )myPArray->vcolours);
- Standard::Free ((Standard_Address& )myPArray->vnormals);
- Standard::Free ((Standard_Address& )myPArray->vtexels);
- Standard::Free ((Standard_Address& )myPArray->edge_vis); /// ???
+ Standard::Free (myPArray->edges);
+ Standard::Free (myPArray->vertices);
+ Standard::Free (myPArray->vcolours);
+ Standard::Free (myPArray->vnormals);
+ Standard::Free (myPArray->vtexels);
+ Standard::Free (myPArray->edge_vis); /// ???
myPArray->edges = NULL;
myPArray->vertices = NULL;
---Purpose: Allocates memory blocks
-- aSize - bytes to allocate
- Free (aStorage:in out Address from Standard);
- ---Purpose: Deallocates memory blocks
- -- aStorage - previously allocated memory block to be freed
+ Free (aStorage: Address from Standard);
+ ---Purpose: Deallocates memory blocks
+ -- aStorage - previously allocated memory block to be freed
- Reallocate(aStorage: in out Address from Standard;
+ ---C++: alias "template <typename T> static inline void Free (T*& thePtr) { Free ((void*)thePtr); thePtr = 0; }"
+
+ Reallocate(aStorage: Address from Standard;
aNewSize: Size from Standard)
returns Address from Standard;
---Purpose: Reallocates memory blocks
}
//=======================================================================
-//function : Free
+//function : FreeAddress
//purpose :
//=======================================================================
-void Standard::Free(Standard_Address& aStorage)
+void Standard::Free (Standard_Address theStorage)
{
- GetMMgr()->Free(aStorage);
+ GetMMgr()->Free(theStorage);
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Address Standard::Reallocate(Standard_Address& aStorage,
- const Standard_Size newSize)
+Standard_Address Standard::Reallocate (Standard_Address theStorage,
+ const Standard_Size theSize)
{
- return GetMMgr()->Reallocate(aStorage, newSize);
+ return GetMMgr()->Reallocate (theStorage, theSize);
}
//=======================================================================
} \
void operator delete (void* theAddress) \
{ \
- Standard::Free ((Standard_Address&)theAddress); \
+ Standard::Free (theAddress); \
} \
DEFINE_STANDARD_ALLOC_ARRAY \
DEFINE_STANDARD_ALLOC_PLACEMENT
//purpose :
//=======================================================================
-void Standard_MMgrOpt::Free(Standard_Address& theStorage)
+void Standard_MMgrOpt::Free(Standard_Address theStorage)
{
// safely return if attempt to free null pointer
if ( ! theStorage )
// otherwise, we have block of big size which shall be simply released
else
FreeMemory (aBlock, RoundSize);
-
- theStorage = NULL;
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Address Standard_MMgrOpt::Reallocate(Standard_Address& theStorage,
+Standard_Address Standard_MMgrOpt::Reallocate(Standard_Address theStorage,
const Standard_Size theNewSize)
{
// if theStorage == NULL, just allocate new memory block
if ( myClear )
memset(((char*)newStorage) + OldSize, 0, theNewSize-OldSize);
}
- theStorage = NULL;
return newStorage;
}
//! Allocate aSize bytes; see class description above
Standard_EXPORT virtual Standard_Address Allocate(const Standard_Size aSize);
- //! Reallocate previously allocated aPtr to a new size; aPtr is nullified.
+ //! Reallocate previously allocated aPtr to a new size; new address is returned.
//! In case that aPtr is null, the function behaves exactly as Allocate.
- Standard_EXPORT virtual Standard_Address Reallocate(Standard_Address& aPtr,
- const Standard_Size aSize);
+ Standard_EXPORT virtual Standard_Address Reallocate (Standard_Address thePtr,
+ const Standard_Size theSize);
- //! Free previously allocated block; aPtr is nullified.
+ //! Free previously allocated block.
//! Note that block can not all blocks are released to the OS by this
//! method (see class description)
- Standard_EXPORT virtual void Free(Standard_Address& aPtr);
+ Standard_EXPORT virtual void Free (Standard_Address thePtr);
//! Release medium-sized blocks of memory in free lists to the system.
//! Returns number of actually freed blocks
//purpose :
//=======================================================================
-void Standard_MMgrRaw::Free(Standard_Address& aStorage)
+void Standard_MMgrRaw::Free(Standard_Address theStorage)
{
- free(aStorage);
- aStorage=NULL;
+ free(theStorage);
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Address Standard_MMgrRaw::Reallocate(Standard_Address& aStorage,
- const Standard_Size newSize)
+Standard_Address Standard_MMgrRaw::Reallocate(Standard_Address theStorage,
+ const Standard_Size theSize)
{
// the size is rounded up to 4 since some OCC classes
// (e.g. TCollection_AsciiString) assume memory to be double word-aligned
- const Standard_Size aRoundSize = (newSize + 3) & ~0x3;
- Standard_Address newStorage = (Standard_Address)realloc(aStorage, aRoundSize);
+ const Standard_Size aRoundSize = (theSize + 3) & ~0x3;
+ Standard_Address newStorage = (Standard_Address)realloc(theStorage, aRoundSize);
if ( ! newStorage )
Standard_OutOfMemory::Raise("Standard_MMgrRaw::Reallocate(): realloc failed");
// Note that it is not possible to ensure that additional memory
// allocated by realloc will be cleared (so as to satisfy myClear mode);
// in order to do that we would need using memset...
- aStorage = NULL;
return newStorage;
}
Standard_EXPORT virtual Standard_Address Allocate(const Standard_Size aSize);
//! Reallocate aPtr to the size aSize.
- //! The pointer aPtr is nullified; new pointer is returned.
- Standard_EXPORT virtual Standard_Address Reallocate(Standard_Address& aPtr,
- const Standard_Size aSize);
+ //! The new pointer is returned.
+ Standard_EXPORT virtual Standard_Address Reallocate(Standard_Address thePtr,
+ const Standard_Size theSize);
//! Free allocated memory. The pointer is nullified.
- Standard_EXPORT virtual void Free(Standard_Address&);
+ Standard_EXPORT virtual void Free (Standard_Address thePtr);
protected:
Standard_Boolean myClear; //! Option to nullify allocated memory
Standard_EXPORT virtual Standard_Address Allocate (const Standard_Size theSize)=0;
//! Reallocate previously allocated memory to contain at least theSize bytes.
- //! In case of success, aPtr should be nullified and new pointer returned.
- Standard_EXPORT virtual Standard_Address Reallocate (Standard_Address& aPtr,
+ //! In case of success, new pointer is returned.
+ Standard_EXPORT virtual Standard_Address Reallocate (Standard_Address thePtr,
const Standard_Size theSize)=0;
//! Frees previously allocated memory at specified address.
- //! The pointer is nullified.
- Standard_EXPORT virtual void Free(Standard_Address& aPtr)=0;
+ Standard_EXPORT virtual void Free(Standard_Address thePtr)=0;
//! Purge internally cached unused memory blocks (if any)
//! by releasing them to the operating system.
//purpose :
//=======================================================================
-void Standard_MMgrTBBalloc::Free(Standard_Address& aStorage)
+void Standard_MMgrTBBalloc::Free (Standard_Address theStorage)
{
- scalable_free(aStorage);
- aStorage=NULL;
+ scalable_free (theStorage);
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Address Standard_MMgrTBBalloc::Reallocate(Standard_Address& aStorage,
- const Standard_Size newSize)
+Standard_Address Standard_MMgrTBBalloc::Reallocate (Standard_Address theStorage,
+ const Standard_Size theSize)
{
// the size is rounded up to 4 since some OCC classes
// (e.g. TCollection_AsciiString) assume memory to be double word-aligned
- const Standard_Size aRoundSize = (newSize + 3) & ~0x3;
- Standard_Address newStorage = (Standard_Address)scalable_realloc(aStorage, aRoundSize);
+ const Standard_Size aRoundSize = (theSize + 3) & ~0x3;
+ Standard_Address newStorage = (Standard_Address)scalable_realloc(theStorage, aRoundSize);
if ( ! newStorage )
Standard_OutOfMemory::Raise("Standard_MMgrTBBalloc::Reallocate(): realloc failed");
// Note that it is not possible to ensure that additional memory
// allocated by realloc will be cleared (so as to satisfy myClear mode);
// in order to do that we would need using memset...
- aStorage = NULL;
return newStorage;
}
Standard_EXPORT virtual Standard_Address Allocate(const Standard_Size aSize);
//! Reallocate aPtr to the size aSize.
- //! The pointer aPtr is nullified; new pointer is returned.
- Standard_EXPORT virtual Standard_Address Reallocate(Standard_Address& aPtr,
- const Standard_Size aSize);
+ //! The new pointer is returned.
+ Standard_EXPORT virtual Standard_Address Reallocate (Standard_Address thePtr,
+ const Standard_Size theSize);
- //! Free allocated memory. The pointer is nullified.
- Standard_EXPORT virtual void Free(Standard_Address&);
+ //! Free allocated memory
+ Standard_EXPORT virtual void Free (Standard_Address thePtr);
protected:
Standard_Boolean myClear; //! Option to nullify allocated memory
//
Storage_Bucket::~Storage_Bucket()
{
- Standard::Free((Standard_Address&)mySpace);
+ Standard::Free (mySpace);
mySpace = 0L;
mySpaceSize = 0;
Clear();
{
Clear();
delete myBuckets[0];
- Standard::Free((Standard_Address&)myBuckets);
+ Standard::Free (myBuckets);
myBuckets = 0L;
}
if (myNumberOfBucket > myNumberOfBucketAllocated) {
Standard_Size e = sizeof(Storage_Bucket*) * myNumberOfBucketAllocated;
- myBuckets = (Storage_Bucket**)Standard::Reallocate((Standard_Address&)myBuckets, e * 2);
+ myBuckets = (Storage_Bucket**)Standard::Reallocate(myBuckets, e * 2);
myNumberOfBucketAllocated *= 2;
}
delete [] &ChangeValue(myLowerRow,myLowerColumn);
// delete the indirection table
- Standard::Free((void*&)anItemPtr);
+ Standard::Free (anItemPtr);
}
//=======================================================================
Standard_ExtString sother = other.mystring;
Standard_Integer newlength = mylength + otherlength;
if (mystring) {
- mystring = Reallocate((void*&)mystring, (newlength+1)*2 );
+ mystring = Reallocate(mystring, (newlength+1)*2 );
memcpy( mystring + mylength, sother, (otherlength+1)*2 );
}
else {
// ----------------------------------------------------------------------------
void TCollection_ExtendedString::Clear()
{
- if (mystring) Standard::Free((void*&)mystring);
+ if (mystring) Standard::Free(mystring);
// mystring = 0L;
mylength = 0;
mystring = Allocate((mylength+1)*2);
const Standard_Integer newlength = fromwhere.mylength;
const Standard_Integer size = (newlength + 1) * 2;
if (mystring) {
- mystring = Reallocate((void*&)mystring, size );
+ mystring = Reallocate(mystring, size );
}
else {
mystring = Allocate( size );
// ----------------------------------------------------------------------------
void TCollection_ExtendedString::Destroy()
{
- if (mystring) Standard::Free((void*&)mystring);
+ if (mystring) Standard::Free(mystring);
mystring = 0L;
}
"Parameter where is negative");
if (mystring) {
- mystring = Reallocate((void*&)mystring,
- (mylength+2)*2);
+ mystring = Reallocate(mystring, (mylength+2)*2);
}
else {
mystring = Allocate((mylength+2)*2);
Standard_Integer newlength = mylength + whatlength;
if (mystring) {
- mystring = Reallocate(
- (void*&)mystring,(newlength+1)*2);
+ mystring = Reallocate(mystring,(newlength+1)*2);
}
else {
mystring = Allocate((newlength+1)*2);
size += (where - 1);
if (size >= mylength){
if (mystring) {
- mystring = Reallocate ((void*&)mystring,(size+1)*2);
+ mystring = Reallocate (mystring,(size+1)*2);
}
else {
mystring = Allocate((size+1)*2);
if (i < whichone) {
buftmp[0] = 0;
- Standard::Free((void*&)buftmp);
+ Standard::Free(buftmp);
}
else {
- Standard::Free((void*&)res.mystring);
+ Standard::Free(res.mystring);
res.mystring = buftmp;
for ( res.mylength=0; buftmp[res.mylength]; ++res.mylength );
}
Standard_PExtCharacter Reallocate(Standard_Address aAddr,
const Standard_Size aLength)
{
- Standard_PExtCharacter pChar;
- //
- pChar= (Standard_PExtCharacter)Standard::Reallocate(aAddr, aLength);
- //
- return pChar;
+ return (Standard_PExtCharacter)Standard::Reallocate(aAddr, aLength);
}
new (&newStack[i]) TopoDS_Iterator(myStack[i]);
myStack[i].~TopoDS_Iterator();
}
- Standard::Free((Standard_Address&)myStack);
+ Standard::Free(myStack);
mySizeOfStack = NewSize;
myStack = newStack;
}
new (&newStack[i]) TopoDS_Iterator(myStack[i]);
myStack[i].~TopoDS_Iterator();
}
- Standard::Free((Standard_Address&)myStack);
+ Standard::Free(myStack);
mySizeOfStack = NewSize;
myStack = newStack;
}
if (myStack)
{
for(int i=0;i<= myTop; i++)myStack[i].~TopoDS_Iterator();
- Standard::Free((Standard_Address&)myStack);
+ Standard::Free(myStack);
}
mySizeOfStack = 0;
myStack = 0L;
}
aTagEntryPtr[0] = '\0';
theTagEntry = aTagEntry;
- Standard::Free ((Standard_Address&)aTagEntry);
+ Standard::Free (aTagEntry);
return Standard_True;
}
}
* aTargetPtr = '\0';
theTarget = aTarget;
- Standard::Free ((Standard_Address&)aTarget);
+ Standard::Free (aTarget);
}
//=======================================================================