diff --git a/src/NCollection/NCollection_BaseAllocator.cxx b/src/NCollection/NCollection_BaseAllocator.cxx index 0c45258927..d536b0b7b8 100644 --- a/src/NCollection/NCollection_BaseAllocator.cxx +++ b/src/NCollection/NCollection_BaseAllocator.cxx @@ -13,9 +13,8 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -// Purpose: Implementation of the BaseAllocator class - #include + #include #include #include @@ -60,62 +59,50 @@ const Handle(NCollection_BaseAllocator)& return pAllocator; } -// global variable to ensure that allocator will be created during loading the library -static Handle(NCollection_BaseAllocator) theAllocInit = - NCollection_BaseAllocator::CommonBaseAllocator(); - -//======================================================================= -/** - * Structure for collecting statistics about blocks of one size - */ -//======================================================================= -struct StorageInfo +namespace { - Standard_Size roundSize; - int nbAlloc; - int nbFree; - StorageInfo() - : roundSize(0), nbAlloc(0), nbFree(0) {} - StorageInfo(Standard_Size theSize) - : roundSize(theSize), nbAlloc(0), nbFree(0) {} -}; + // global variable to ensure that allocator will be created during loading the library + static Handle(NCollection_BaseAllocator) theAllocInit = NCollection_BaseAllocator::CommonBaseAllocator(); -//======================================================================= -/** - * Static data map (block_size -> StorageInfo) - */ -//======================================================================= -static NCollection_DataMap& StorageMap() -{ - static NCollection_IncAllocator TheAlloc; - static NCollection_DataMap - TheMap (1, & TheAlloc); - return TheMap; -} + //! Structure for collecting statistics about blocks of one size + struct StorageInfo + { + Standard_Size roundSize; + int nbAlloc; + int nbFree; + StorageInfo() : roundSize(0), nbAlloc(0), nbFree(0) {} + StorageInfo(Standard_Size theSize) : roundSize(theSize), nbAlloc(0), nbFree(0) {} + }; -//======================================================================= -/** - * Static data map (address -> AllocationID) - */ -//======================================================================= -static NCollection_DataMap& StorageIDMap() -{ - static NCollection_IncAllocator TheAlloc; - static NCollection_DataMap - TheMap (1, & TheAlloc); - return TheMap; -} + //! Static data map (block_size -> StorageInfo) + static NCollection_DataMap& StorageMap() + { + static NCollection_IncAllocator TheAlloc; + static NCollection_DataMap TheMap (1, & TheAlloc); + return TheMap; + } -//======================================================================= -/** - * Static map (AllocationID) - */ -//======================================================================= -static NCollection_Map& StorageIDSet() -{ - static NCollection_IncAllocator TheAlloc; - static NCollection_Map TheMap (1, & TheAlloc); - return TheMap; + //! Static data map (address -> AllocationID) + static NCollection_DataMap& StorageIDMap() + { + static NCollection_IncAllocator TheAlloc; + static NCollection_DataMap TheMap (1, & TheAlloc); + return TheMap; + } + + //! Static map (AllocationID) + static NCollection_Map& StorageIDSet() + { + static NCollection_IncAllocator TheAlloc; + static NCollection_Map TheMap (1, & TheAlloc); + return TheMap; + } + + // dummy function for break point + inline void place_for_break_point () {} + + //! Static value of the current allocation ID. It provides unique numbering of allocation events. + static Standard_Size CurrentID = 0; } //======================================================================= @@ -147,14 +134,6 @@ Standard_EXPORT Standard_Size& StandardCallBack_CatchID() return Value; } -//======================================================================= -/** - * Static value of the current allocation ID. It provides unique - * numbering of allocation events. - */ -//======================================================================= -static Standard_Size CurrentID = 0; - //======================================================================= /** * Exported function to reset the callback system to the initial state @@ -170,11 +149,6 @@ Standard_EXPORT void StandardCallBack_Reset() StandardCallBack_CatchID() = 0; } -namespace { - // dummy function for break point - inline void place_for_break_point () {} -} - //======================================================================= //function : StandardCallBack //purpose : Callback function to register alloc/free calls diff --git a/src/OSD/OSD_MAllocHook.cxx b/src/OSD/OSD_MAllocHook.cxx index 6905f2fa57..f1f61e8bcc 100644 --- a/src/OSD/OSD_MAllocHook.cxx +++ b/src/OSD/OSD_MAllocHook.cxx @@ -246,29 +246,31 @@ void OSD_MAllocHook::LogFileHandler::Close() //function : LogFileHandler::MakeReport //purpose : //======================================================================= - -struct StorageInfo +namespace { - Standard_Size size; - Standard_Integer nbAlloc; - Standard_Integer nbFree; - Standard_Integer nbLeftPeak; - std::set alive; - - StorageInfo(Standard_Size theSize = 0) - : size (theSize), - nbAlloc (0), - nbFree (0), - nbLeftPeak(0), - alive() + struct StorageInfo { - } + Standard_Size size; + Standard_Integer nbAlloc; + Standard_Integer nbFree; + Standard_Integer nbLeftPeak; + std::set alive; - bool operator < (const StorageInfo& theOther) const - { - return size < theOther.size; - } -}; + StorageInfo(Standard_Size theSize = 0) + : size (theSize), + nbAlloc (0), + nbFree (0), + nbLeftPeak(0), + alive() + { + } + + bool operator < (const StorageInfo& theOther) const + { + return size < theOther.size; + } + }; +} Standard_Boolean OSD_MAllocHook::LogFileHandler::MakeReport (const char* theLogFile,