mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0030846: Foundation Classes - StorageInfo violates the C++ One Definition Rule
Local definitions have been put into anonymouse namespace within files OSD_MAllocHook.cxx and NCollection_BaseAllocator.cxx.
This commit is contained in:
parent
3f50e94e33
commit
9eefb360a7
@ -13,9 +13,8 @@
|
|||||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
// commercial license or contractual agreement.
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
// Purpose: Implementation of the BaseAllocator class
|
|
||||||
|
|
||||||
#include <NCollection_BaseAllocator.hxx>
|
#include <NCollection_BaseAllocator.hxx>
|
||||||
|
|
||||||
#include <NCollection_IncAllocator.hxx>
|
#include <NCollection_IncAllocator.hxx>
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
#include <NCollection_Map.hxx>
|
#include <NCollection_Map.hxx>
|
||||||
@ -60,62 +59,50 @@ const Handle(NCollection_BaseAllocator)&
|
|||||||
return pAllocator;
|
return pAllocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
// global variable to ensure that allocator will be created during loading the library
|
namespace
|
||||||
static Handle(NCollection_BaseAllocator) theAllocInit =
|
|
||||||
NCollection_BaseAllocator::CommonBaseAllocator();
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
/**
|
|
||||||
* Structure for collecting statistics about blocks of one size
|
|
||||||
*/
|
|
||||||
//=======================================================================
|
|
||||||
struct StorageInfo
|
|
||||||
{
|
{
|
||||||
Standard_Size roundSize;
|
// global variable to ensure that allocator will be created during loading the library
|
||||||
int nbAlloc;
|
static Handle(NCollection_BaseAllocator) theAllocInit = NCollection_BaseAllocator::CommonBaseAllocator();
|
||||||
int nbFree;
|
|
||||||
StorageInfo()
|
|
||||||
: roundSize(0), nbAlloc(0), nbFree(0) {}
|
|
||||||
StorageInfo(Standard_Size theSize)
|
|
||||||
: roundSize(theSize), nbAlloc(0), nbFree(0) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
//=======================================================================
|
//! Structure for collecting statistics about blocks of one size
|
||||||
/**
|
struct StorageInfo
|
||||||
* Static data map (block_size -> StorageInfo)
|
{
|
||||||
*/
|
Standard_Size roundSize;
|
||||||
//=======================================================================
|
int nbAlloc;
|
||||||
static NCollection_DataMap<Standard_Size, StorageInfo>& StorageMap()
|
int nbFree;
|
||||||
{
|
StorageInfo() : roundSize(0), nbAlloc(0), nbFree(0) {}
|
||||||
static NCollection_IncAllocator TheAlloc;
|
StorageInfo(Standard_Size theSize) : roundSize(theSize), nbAlloc(0), nbFree(0) {}
|
||||||
static NCollection_DataMap<Standard_Size, StorageInfo>
|
};
|
||||||
TheMap (1, & TheAlloc);
|
|
||||||
return TheMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//! Static data map (block_size -> StorageInfo)
|
||||||
/**
|
static NCollection_DataMap<Standard_Size, StorageInfo>& StorageMap()
|
||||||
* Static data map (address -> AllocationID)
|
{
|
||||||
*/
|
static NCollection_IncAllocator TheAlloc;
|
||||||
//=======================================================================
|
static NCollection_DataMap<Standard_Size, StorageInfo> TheMap (1, & TheAlloc);
|
||||||
static NCollection_DataMap<Standard_Address, Standard_Size>& StorageIDMap()
|
return TheMap;
|
||||||
{
|
}
|
||||||
static NCollection_IncAllocator TheAlloc;
|
|
||||||
static NCollection_DataMap<Standard_Address, Standard_Size>
|
|
||||||
TheMap (1, & TheAlloc);
|
|
||||||
return TheMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//! Static data map (address -> AllocationID)
|
||||||
/**
|
static NCollection_DataMap<Standard_Address, Standard_Size>& StorageIDMap()
|
||||||
* Static map (AllocationID)
|
{
|
||||||
*/
|
static NCollection_IncAllocator TheAlloc;
|
||||||
//=======================================================================
|
static NCollection_DataMap<Standard_Address, Standard_Size> TheMap (1, & TheAlloc);
|
||||||
static NCollection_Map<Standard_Size>& StorageIDSet()
|
return TheMap;
|
||||||
{
|
}
|
||||||
static NCollection_IncAllocator TheAlloc;
|
|
||||||
static NCollection_Map<Standard_Size> TheMap (1, & TheAlloc);
|
//! Static map (AllocationID)
|
||||||
return TheMap;
|
static NCollection_Map<Standard_Size>& StorageIDSet()
|
||||||
|
{
|
||||||
|
static NCollection_IncAllocator TheAlloc;
|
||||||
|
static NCollection_Map<Standard_Size> 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;
|
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
|
* Exported function to reset the callback system to the initial state
|
||||||
@ -170,11 +149,6 @@ Standard_EXPORT void StandardCallBack_Reset()
|
|||||||
StandardCallBack_CatchID() = 0;
|
StandardCallBack_CatchID() = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
// dummy function for break point
|
|
||||||
inline void place_for_break_point () {}
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : StandardCallBack
|
//function : StandardCallBack
|
||||||
//purpose : Callback function to register alloc/free calls
|
//purpose : Callback function to register alloc/free calls
|
||||||
|
@ -246,29 +246,31 @@ void OSD_MAllocHook::LogFileHandler::Close()
|
|||||||
//function : LogFileHandler::MakeReport
|
//function : LogFileHandler::MakeReport
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
namespace
|
||||||
struct StorageInfo
|
|
||||||
{
|
{
|
||||||
Standard_Size size;
|
struct StorageInfo
|
||||||
Standard_Integer nbAlloc;
|
|
||||||
Standard_Integer nbFree;
|
|
||||||
Standard_Integer nbLeftPeak;
|
|
||||||
std::set<unsigned long> alive;
|
|
||||||
|
|
||||||
StorageInfo(Standard_Size theSize = 0)
|
|
||||||
: size (theSize),
|
|
||||||
nbAlloc (0),
|
|
||||||
nbFree (0),
|
|
||||||
nbLeftPeak(0),
|
|
||||||
alive()
|
|
||||||
{
|
{
|
||||||
}
|
Standard_Size size;
|
||||||
|
Standard_Integer nbAlloc;
|
||||||
|
Standard_Integer nbFree;
|
||||||
|
Standard_Integer nbLeftPeak;
|
||||||
|
std::set<unsigned long> alive;
|
||||||
|
|
||||||
bool operator < (const StorageInfo& theOther) const
|
StorageInfo(Standard_Size theSize = 0)
|
||||||
{
|
: size (theSize),
|
||||||
return size < theOther.size;
|
nbAlloc (0),
|
||||||
}
|
nbFree (0),
|
||||||
};
|
nbLeftPeak(0),
|
||||||
|
alive()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const StorageInfo& theOther) const
|
||||||
|
{
|
||||||
|
return size < theOther.size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Standard_Boolean OSD_MAllocHook::LogFileHandler::MakeReport
|
Standard_Boolean OSD_MAllocHook::LogFileHandler::MakeReport
|
||||||
(const char* theLogFile,
|
(const char* theLogFile,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user