diff --git a/src/AdvApp2Var/AdvApp2Var_SysBase.cxx b/src/AdvApp2Var/AdvApp2Var_SysBase.cxx index 5e134ce9e3..15861f8b08 100644 --- a/src/AdvApp2Var/AdvApp2Var_SysBase.cxx +++ b/src/AdvApp2Var/AdvApp2Var_SysBase.cxx @@ -107,12 +107,12 @@ int mcrcomm_(integer *kop, 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 @@ -2351,7 +2351,7 @@ L1100: } } else { /* DE-ALLOCATION SYSTEM */ - mcrfree_(&ibyte, reinterpret_cast (&iaddr), &ier); + mcrfree_(&ibyte, iaddr, &ier); if (ier != 0) { goto L9002; } @@ -2510,14 +2510,12 @@ int AdvApp2Var_SysBase::mcrfill_(integer *size, //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; } @@ -2553,13 +2551,13 @@ int mcrfree_(integer *,//ibyte, //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; } @@ -2963,7 +2961,7 @@ int AdvApp2Var_SysBase::mcrrqst_(integer *iunit, /* ELSE */ /* ALLOCATION SYSTEME */ ksys = heap_allocation; - mcrgetv_(&ibyte, reinterpret_cast (&iaddr), &ier); + mcrgetv_(&ibyte, &iaddr, &ier); if (ier != 0) { goto L9003; } diff --git a/src/BOPCol/BOPCol_Array1.hxx b/src/BOPCol/BOPCol_Array1.hxx old mode 100644 new mode 100755 index cce75cdadb..768fcfca6e --- a/src/BOPCol/BOPCol_Array1.hxx +++ b/src/BOPCol/BOPCol_Array1.hxx @@ -68,7 +68,7 @@ template class BOPCol_MemBlock { for (i=0; iFree((Standard_Address&)myData); + myAllocator->Free(myData); // myData=NULL; mySize=0; @@ -177,10 +177,8 @@ template class BOPCol_Array1 { while(pBlock) { pNext=pBlock->Next(); // - //pBlock->~BOPCol_MemBlock (); pBlock->~BOPCol_XMemBlock(); - //pBlock->Clear(); - myAllocator->Free((Standard_Address&)pBlock); + myAllocator->Free(pBlock); // pBlock=pNext; } diff --git a/src/BOPDS/BOPDS_PassKey.lxx b/src/BOPDS/BOPDS_PassKey.lxx index 7124cffa75..6eeae87b96 100644 --- a/src/BOPDS/BOPDS_PassKey.lxx +++ b/src/BOPDS/BOPDS_PassKey.lxx @@ -116,7 +116,7 @@ static myNbIds=0; mySum=0; if (myPtr) { - myAllocator->Free((Standard_Address)myPtr); + myAllocator->Free(myPtr); myPtr=NULL; } } diff --git a/src/BOPDS/BOPDS_PaveBlock.cxx b/src/BOPDS/BOPDS_PaveBlock.cxx old mode 100644 new mode 100755 index f75bac17ec..2512e0fcce --- a/src/BOPDS/BOPDS_PaveBlock.cxx +++ b/src/BOPDS/BOPDS_PaveBlock.cxx @@ -317,7 +317,7 @@ static for (i=0; iFree((Standard_Address&)pPaves); + myAllocator->Free(pPaves); } //======================================================================= diff --git a/src/BOPTools/BOPTools_Set.lxx b/src/BOPTools/BOPTools_Set.lxx old mode 100644 new mode 100755 index 32d7dcc75e..957d85ead6 --- a/src/BOPTools/BOPTools_Set.lxx +++ b/src/BOPTools/BOPTools_Set.lxx @@ -162,7 +162,7 @@ static for (i=0; iFree((Standard_Address&)pShapes); + myAllocator->Free(pShapes); } //======================================================================= //function : AddEdges @@ -220,7 +220,7 @@ static for (i=0; iFree((Standard_Address&)pShapes); + myAllocator->Free(pShapes); } //======================================================================= //function : IsEqual diff --git a/src/DBC/DBC_VArray.gxx b/src/DBC/DBC_VArray.gxx index d567d9e439..38857deca3 100644 --- a/src/DBC/DBC_VArray.gxx +++ b/src/DBC/DBC_VArray.gxx @@ -176,7 +176,7 @@ void DBC_VArray::Resize (const Standard_Integer NewSize) 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(); @@ -291,7 +291,7 @@ void DBC_VArray::Destroy() ptrtmp->DBC_VArrayTNode::~DBC_VArrayTNode(); ptrtmp++; } - Standard::Free((Standard_Address&)myData); + Standard::Free(myData); myData = 0L; } #endif diff --git a/src/FSD/FSD_BinaryFile.cxx b/src/FSD/FSD_BinaryFile.cxx index 459c03b002..6a376e0681 100644 --- a/src/FSD/FSD_BinaryFile.cxx +++ b/src/FSD/FSD_BinaryFile.cxx @@ -1077,7 +1077,7 @@ void FSD_BinaryFile::ReadString(TCollection_AsciiString& aString) 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(); @@ -1138,7 +1138,7 @@ void FSD_BinaryFile::ReadExtendedString(TCollection_ExtendedString& aString) c[i] = InverseExtChar (c[i]); #endif aString = c; - Standard::Free((Standard_Address&)c); + Standard::Free(c); } else { aString.Clear(); diff --git a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx index c25c62082d..094f2cf219 100644 --- a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx +++ b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx @@ -98,46 +98,46 @@ void Graphic3d_ArrayOfPrimitives::Destroy () { 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 diff --git a/src/Graphic3d/Graphic3d_Strips.cxx b/src/Graphic3d/Graphic3d_Strips.cxx index fac44ab309..3acdf5c82a 100644 --- a/src/Graphic3d/Graphic3d_Strips.cxx +++ b/src/Graphic3d/Graphic3d_Strips.cxx @@ -245,10 +245,10 @@ to index it in the edges array */ 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); } @@ -302,7 +302,7 @@ void Graphic3d_Strips :: STRIPT_GET_STRIP ( Standard_Integer& NBTRIANGLES, { NBTRIANGLES = 0; current_stript.t = 0; - Standard::Free((void*&)trianglesptr); + Standard::Free(trianglesptr); return; } @@ -886,10 +886,10 @@ to index it in the edges array */ { cedge = edges[ivert]; edges[ivert] = cedge->next; - Standard::Free((void*&)cedge); + Standard::Free(cedge); } } - Standard::Free((void*&)edges); + Standard::Free(edges); } @@ -943,7 +943,7 @@ void Graphic3d_Strips :: STRIPQ_GET_STRIP ( Standard_Integer& NBQUAD,Standard_In { NBQUAD = 0; current_stripq.q = 0; - Standard::Free((void*&)quadranglesptr); + Standard::Free(quadranglesptr); return; } /* Now search the best strip from this quadrangle diff --git a/src/NCollection/NCollection_BaseAllocator.cxx b/src/NCollection/NCollection_BaseAllocator.cxx index ab2bc11e92..93f1f791ae 100644 --- a/src/NCollection/NCollection_BaseAllocator.cxx +++ b/src/NCollection/NCollection_BaseAllocator.cxx @@ -43,7 +43,7 @@ void* NCollection_BaseAllocator::Allocate(const size_t size) void NCollection_BaseAllocator::Free(void *anAddress) { - if (anAddress) Standard::Free((Standard_Address&)anAddress); + if (anAddress) Standard::Free(anAddress); } //======================================================================= diff --git a/src/NCollection/NCollection_LocalArray.hxx b/src/NCollection/NCollection_LocalArray.hxx index 35bec281d5..c250cc55c1 100644 --- a/src/NCollection/NCollection_LocalArray.hxx +++ b/src/NCollection/NCollection_LocalArray.hxx @@ -65,7 +65,7 @@ protected: void Deallocate() { if (myPtr != myBuffer) - Standard::Free (*(Standard_Address*)&myPtr); + Standard::Free (myPtr); } protected: diff --git a/src/NCollection/NCollection_UtfString.hxx b/src/NCollection/NCollection_UtfString.hxx index e53e9d3bcd..f1bc6d5c13 100755 --- a/src/NCollection/NCollection_UtfString.hxx +++ b/src/NCollection/NCollection_UtfString.hxx @@ -232,9 +232,7 @@ private: //! @name low-level methods //! 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. diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index 3fbb60bb55..d41c89abf6 100755 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -57,12 +57,12 @@ namespace // ======================================================================= 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; diff --git a/src/Standard/Standard.cdl b/src/Standard/Standard.cdl index c34d54df7e..9abe1ebae1 100644 --- a/src/Standard/Standard.cdl +++ b/src/Standard/Standard.cdl @@ -133,11 +133,13 @@ is ---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 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 diff --git a/src/Standard/Standard.cxx b/src/Standard/Standard.cxx index f1de0626af..a613bc92c5 100644 --- a/src/Standard/Standard.cxx +++ b/src/Standard/Standard.cxx @@ -183,13 +183,13 @@ Standard_Address Standard::Allocate(const Standard_Size size) } //======================================================================= -//function : Free +//function : FreeAddress //purpose : //======================================================================= -void Standard::Free(Standard_Address& aStorage) +void Standard::Free (Standard_Address theStorage) { - GetMMgr()->Free(aStorage); + GetMMgr()->Free(theStorage); } //======================================================================= @@ -197,10 +197,10 @@ void Standard::Free(Standard_Address& aStorage) //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); } //======================================================================= diff --git a/src/Standard/Standard_DefineAlloc.hxx b/src/Standard/Standard_DefineAlloc.hxx index 509f6d1586..f73142544c 100644 --- a/src/Standard/Standard_DefineAlloc.hxx +++ b/src/Standard/Standard_DefineAlloc.hxx @@ -61,7 +61,7 @@ } \ void operator delete (void* theAddress) \ { \ - Standard::Free ((Standard_Address&)theAddress); \ + Standard::Free (theAddress); \ } \ DEFINE_STANDARD_ALLOC_ARRAY \ DEFINE_STANDARD_ALLOC_PLACEMENT diff --git a/src/Standard/Standard_MMgrOpt.cxx b/src/Standard/Standard_MMgrOpt.cxx index 6b8d9b22eb..8542e245c0 100644 --- a/src/Standard/Standard_MMgrOpt.cxx +++ b/src/Standard/Standard_MMgrOpt.cxx @@ -475,7 +475,7 @@ Standard_Address Standard_MMgrOpt::Allocate(const Standard_Size aSize) //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 ) @@ -510,8 +510,6 @@ void Standard_MMgrOpt::Free(Standard_Address& theStorage) // otherwise, we have block of big size which shall be simply released else FreeMemory (aBlock, RoundSize); - - theStorage = NULL; } //======================================================================= @@ -704,7 +702,7 @@ void Standard_MMgrOpt::FreePools() //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 @@ -732,7 +730,6 @@ Standard_Address Standard_MMgrOpt::Reallocate(Standard_Address& theStorage, if ( myClear ) memset(((char*)newStorage) + OldSize, 0, theNewSize-OldSize); } - theStorage = NULL; return newStorage; } diff --git a/src/Standard/Standard_MMgrOpt.hxx b/src/Standard/Standard_MMgrOpt.hxx index 536df052c0..c97c059e12 100644 --- a/src/Standard/Standard_MMgrOpt.hxx +++ b/src/Standard/Standard_MMgrOpt.hxx @@ -97,15 +97,15 @@ class Standard_MMgrOpt : public Standard_MMgrRoot //! 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 diff --git a/src/Standard/Standard_MMgrRaw.cxx b/src/Standard/Standard_MMgrRaw.cxx index f6906656c0..964cf12bf4 100644 --- a/src/Standard/Standard_MMgrRaw.cxx +++ b/src/Standard/Standard_MMgrRaw.cxx @@ -50,10 +50,9 @@ Standard_Address Standard_MMgrRaw::Allocate(const Standard_Size aSize) //purpose : //======================================================================= -void Standard_MMgrRaw::Free(Standard_Address& aStorage) +void Standard_MMgrRaw::Free(Standard_Address theStorage) { - free(aStorage); - aStorage=NULL; + free(theStorage); } //======================================================================= @@ -61,18 +60,17 @@ void Standard_MMgrRaw::Free(Standard_Address& aStorage) //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; } diff --git a/src/Standard/Standard_MMgrRaw.hxx b/src/Standard/Standard_MMgrRaw.hxx index a15560fd7c..a4605f8b0e 100644 --- a/src/Standard/Standard_MMgrRaw.hxx +++ b/src/Standard/Standard_MMgrRaw.hxx @@ -46,12 +46,12 @@ class Standard_MMgrRaw : public Standard_MMgrRoot 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 diff --git a/src/Standard/Standard_MMgrRoot.hxx b/src/Standard/Standard_MMgrRoot.hxx index 32d6f7ef6c..b314e40e2f 100644 --- a/src/Standard/Standard_MMgrRoot.hxx +++ b/src/Standard/Standard_MMgrRoot.hxx @@ -45,13 +45,12 @@ class Standard_MMgrRoot 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. diff --git a/src/Standard/Standard_MMgrTBBalloc.cxx b/src/Standard/Standard_MMgrTBBalloc.cxx index 4ae1bdae77..9a94f160ea 100644 --- a/src/Standard/Standard_MMgrTBBalloc.cxx +++ b/src/Standard/Standard_MMgrTBBalloc.cxx @@ -65,10 +65,9 @@ Standard_Address Standard_MMgrTBBalloc::Allocate(const Standard_Size aSize) //purpose : //======================================================================= -void Standard_MMgrTBBalloc::Free(Standard_Address& aStorage) +void Standard_MMgrTBBalloc::Free (Standard_Address theStorage) { - scalable_free(aStorage); - aStorage=NULL; + scalable_free (theStorage); } //======================================================================= @@ -76,18 +75,17 @@ void Standard_MMgrTBBalloc::Free(Standard_Address& aStorage) //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; } diff --git a/src/Standard/Standard_MMgrTBBalloc.hxx b/src/Standard/Standard_MMgrTBBalloc.hxx index a07e7f3073..3cf74cb16a 100644 --- a/src/Standard/Standard_MMgrTBBalloc.hxx +++ b/src/Standard/Standard_MMgrTBBalloc.hxx @@ -47,12 +47,12 @@ class Standard_MMgrTBBalloc : public Standard_MMgrRoot 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 diff --git a/src/Storage/Storage_Schema.cxx b/src/Storage/Storage_Schema.cxx index 500a2af841..cb152d300c 100644 --- a/src/Storage/Storage_Schema.cxx +++ b/src/Storage/Storage_Schema.cxx @@ -70,7 +70,7 @@ typedef NCollection_DataMap 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; } diff --git a/src/TCollection/TCollection_Array2.gxx b/src/TCollection/TCollection_Array2.gxx index 73f958f2be..82445f6f0b 100644 --- a/src/TCollection/TCollection_Array2.gxx +++ b/src/TCollection/TCollection_Array2.gxx @@ -120,7 +120,7 @@ void TCollection_Array2::Destroy () delete [] &ChangeValue(myLowerRow,myLowerColumn); // delete the indirection table - Standard::Free((void*&)anItemPtr); + Standard::Free (anItemPtr); } //======================================================================= diff --git a/src/TCollection/TCollection_ExtendedString.cxx b/src/TCollection/TCollection_ExtendedString.cxx index 55ad098773..e0228a99e2 100644 --- a/src/TCollection/TCollection_ExtendedString.cxx +++ b/src/TCollection/TCollection_ExtendedString.cxx @@ -288,7 +288,7 @@ void TCollection_ExtendedString::AssignCat 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 { @@ -328,7 +328,7 @@ void TCollection_ExtendedString::ChangeAll(const Standard_ExtCharacter aChar, // ---------------------------------------------------------------------------- void TCollection_ExtendedString::Clear() { - if (mystring) Standard::Free((void*&)mystring); + if (mystring) Standard::Free(mystring); // mystring = 0L; mylength = 0; mystring = Allocate((mylength+1)*2); @@ -345,7 +345,7 @@ void TCollection_ExtendedString::Copy (const TCollection_ExtendedString& fromwhe 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 ); @@ -366,7 +366,7 @@ void TCollection_ExtendedString::Copy (const TCollection_ExtendedString& fromwhe // ---------------------------------------------------------------------------- void TCollection_ExtendedString::Destroy() { - if (mystring) Standard::Free((void*&)mystring); + if (mystring) Standard::Free(mystring); mystring = 0L; } @@ -384,8 +384,7 @@ void TCollection_ExtendedString::Insert(const Standard_Integer where, "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); @@ -412,8 +411,7 @@ void TCollection_ExtendedString::Insert(const Standard_Integer where, 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); @@ -656,7 +654,7 @@ void TCollection_ExtendedString::SetValue 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); @@ -754,10 +752,10 @@ TCollection_ExtendedString TCollection_ExtendedString::Token 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 ); } @@ -914,9 +912,5 @@ Standard_PExtCharacter Allocate(const Standard_Size aLength) 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); } diff --git a/src/TopExp/TopExp_Explorer.cxx b/src/TopExp/TopExp_Explorer.cxx index b79f2fc9c1..b410bfc2c2 100644 --- a/src/TopExp/TopExp_Explorer.cxx +++ b/src/TopExp/TopExp_Explorer.cxx @@ -174,7 +174,7 @@ void TopExp_Explorer::Next() new (&newStack[i]) TopoDS_Iterator(myStack[i]); myStack[i].~TopoDS_Iterator(); } - Standard::Free((Standard_Address&)myStack); + Standard::Free(myStack); mySizeOfStack = NewSize; myStack = newStack; } @@ -200,7 +200,7 @@ void TopExp_Explorer::Next() new (&newStack[i]) TopoDS_Iterator(myStack[i]); myStack[i].~TopoDS_Iterator(); } - Standard::Free((Standard_Address&)myStack); + Standard::Free(myStack); mySizeOfStack = NewSize; myStack = newStack; } @@ -239,7 +239,7 @@ void TopExp_Explorer::Destroy() 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; diff --git a/src/XmlObjMgt/XmlObjMgt.cxx b/src/XmlObjMgt/XmlObjMgt.cxx index 1d67a8d8c8..0d863a560a 100644 --- a/src/XmlObjMgt/XmlObjMgt.cxx +++ b/src/XmlObjMgt/XmlObjMgt.cxx @@ -204,7 +204,7 @@ Standard_Boolean XmlObjMgt::GetTagEntryString } aTagEntryPtr[0] = '\0'; theTagEntry = aTagEntry; - Standard::Free ((Standard_Address&)aTagEntry); + Standard::Free (aTagEntry); return Standard_True; } @@ -259,7 +259,7 @@ void XmlObjMgt::SetTagEntryString (XmlObjMgt_DOMString& theTarget, } * aTargetPtr = '\0'; theTarget = aTarget; - Standard::Free ((Standard_Address&)aTarget); + Standard::Free (aTarget); } //=======================================================================