diff --git a/tools/inc/tools/mempool.hxx b/tools/inc/tools/mempool.hxx index a96a024d4b27..7e38ff3003c3 100644 --- a/tools/inc/tools/mempool.hxx +++ b/tools/inc/tools/mempool.hxx @@ -28,7 +28,7 @@ #define _SVMEMPOOL_HXX #include "tools/toolsdllapi.h" -#include +#include "tools/solar.h" // ---------------- // - FixedMemPool - @@ -39,9 +39,11 @@ struct FixedMemPool_Impl; class TOOLS_DLLPUBLIC FixedMemPool { FixedMemPool_Impl * m_pImpl; + char const * m_pTypeName; public: - FixedMemPool( USHORT nTypeSize, + FixedMemPool( char const * pTypeName, + USHORT nTypeSize, USHORT nInitSize = 512, USHORT nGrowSize = 256 ); ~FixedMemPool(); @@ -97,8 +99,11 @@ IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) DECL_FIXEDMEMPOOL_NEW_INLINE( Class, aPool ) \ DECL_FIXEDMEMPOOL_DEL_INLINE( Class, aPool ) +#define IMPL_FIXEDMEMPOOL_STRING(x) IMPL_FIXEDMEMPOOL_MAKESTRING(x) +#define IMPL_FIXEDMEMPOOL_MAKESTRING(x) #x + #define IMPL_FIXEDMEMPOOL_NEWDEL( Class, InitSize, GrowSize) \ - FixedMemPool Class::aPool( sizeof( Class ), (InitSize), (GrowSize) ); + FixedMemPool Class::aPool( IMPL_FIXEDMEMPOOL_STRING( Class ), sizeof( Class ), (InitSize), (GrowSize) ); #define DECL_FIXEDMEMPOOL_NEWDEL_DLL( Class ) \ private: \ @@ -108,13 +113,13 @@ IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) DECL_FIXEDMEMPOOL_DEL_DECL(); #define IMPL_FIXEDMEMPOOL_NEWDEL_DLL( Class, InitSize, GrowSize) \ - FixedMemPool Class::aPool( sizeof( Class ), (InitSize), (GrowSize) ); \ + FixedMemPool Class::aPool( IMPL_FIXEDMEMPOOL_STRING( Class ), sizeof( Class ), (InitSize), (GrowSize) ); \ DECL_FIXEDMEMPOOL_NEW_IMPL( Class ) \ IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) \ DECL_FIXEDMEMPOOL_DEL_IMPL( Class ) \ IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) -#define INIT_FIXEDMEMPOOL_NEWDEL_DLL( class, aPool, InitSize, GrowSize ) \ - aPool( sizeof( class ), InitSize, GrowSize ) +#define INIT_FIXEDMEMPOOL_NEWDEL_DLL( Class, aPool, InitSize, GrowSize ) \ + aPool( IMPL_FIXEDMEMPOOL_STRING( Class ), sizeof( Class ), (InitSize), (GrowSize) ) #endif // _SVMEMPOOL_HXX diff --git a/tools/source/memtools/mempool.cxx b/tools/source/memtools/mempool.cxx index 45d6d2ea9367..185ba731b3a2 100644 --- a/tools/source/memtools/mempool.cxx +++ b/tools/source/memtools/mempool.cxx @@ -28,7 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_tools.hxx" -#include +#include "tools/mempool.hxx" +#include "osl/diagnose.h" #include "rtl/alloc.h" #ifndef INCLUDED_STDIO_H @@ -42,11 +43,13 @@ *************************************************************************/ FixedMemPool::FixedMemPool ( - USHORT _nTypeSize, USHORT, USHORT) + char const * pTypeName, USHORT nTypeSize, USHORT, USHORT) + : m_pTypeName (pTypeName) { char name[RTL_CACHE_NAME_LENGTH + 1]; - snprintf (name, sizeof(name), "FixedMemPool_%d", (int)_nTypeSize); - m_pImpl = (FixedMemPool_Impl*)rtl_cache_create (name, _nTypeSize, 0, NULL, NULL, NULL, 0, NULL, 0); + snprintf (name, sizeof(name), "FixedMemPool_%d", (int)nTypeSize); + m_pImpl = (FixedMemPool_Impl*)rtl_cache_create (name, nTypeSize, 0, NULL, NULL, NULL, 0, NULL, 0); + OSL_TRACE("FixedMemPool::ctor(\"%s\"): %p", m_pTypeName, m_pImpl); } /************************************************************************* @@ -57,7 +60,8 @@ FixedMemPool::FixedMemPool ( FixedMemPool::~FixedMemPool() { - rtl_cache_destroy ((rtl_cache_type*)(m_pImpl)); + OSL_TRACE("FixedMemPool::dtor(\"%s\"): %p", m_pTypeName, m_pImpl); + rtl_cache_destroy ((rtl_cache_type*)(m_pImpl)), m_pImpl = 0; } /************************************************************************* diff --git a/tools/workben/makefile.mk b/tools/workben/makefile.mk index 73d5753fe233..b73e8da83686 100644 --- a/tools/workben/makefile.mk +++ b/tools/workben/makefile.mk @@ -62,6 +62,11 @@ APP3TARGET = inetmimetest APP3OBJS = $(OBJ)$/inetmimetest.obj APP3STDLIBS = $(SALLIB) $(TOOLSLIB) +APP4TARGET = mempooltest +APP4OBJS = $(OBJ)$/mempooltest.obj +APP4STDLIBS = $(TOOLSLIB) +APP4RPATH = UREBIN + # APP3TARGET = tldem # APP3OBJS = $(OBJ)$/tldem.obj # .IF "$(GUI)" == "UNX" diff --git a/tools/workben/mempooltest.cxx b/tools/workben/mempooltest.cxx new file mode 100644 index 000000000000..bf00343bc9d6 --- /dev/null +++ b/tools/workben/mempooltest.cxx @@ -0,0 +1,18 @@ +#include "tools/mempool.hxx" + +struct MempoolTest +{ + int m_int; + + DECL_FIXEDMEMPOOL_NEWDEL(MempoolTest); +}; + +IMPL_FIXEDMEMPOOL_NEWDEL(MempoolTest, 0, 0); + +int main() +{ + MempoolTest * p = new MempoolTest(); + if (p != 0) + delete p; + return 1; +}