diff options
author | Matthias Huetsch [mhu] <matthias.huetsch@oracle.com> | 2010-11-25 16:04:27 +0100 |
---|---|---|
committer | Matthias Huetsch [mhu] <matthias.huetsch@oracle.com> | 2010-11-25 16:04:27 +0100 |
commit | 4220253ce32d0fe9426ad6d93011126c71d3fb7c (patch) | |
tree | 996057fcdd3661ccccff05c201cc9fef80a4a011 /tools | |
parent | Update from master repository (DEV300_m83). (diff) | |
parent | #i115784# rsc: fix memory errors uncovered by valgrind and other tools. (diff) | |
download | core-4220253ce32d0fe9426ad6d93011126c71d3fb7c.tar.gz core-4220253ce32d0fe9426ad6d93011126c71d3fb7c.zip |
Update from sibling repository.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/inc/tools/mempool.hxx | 17 | ||||
-rw-r--r-- | tools/source/memtools/mempool.cxx | 14 | ||||
-rw-r--r-- | tools/workben/makefile.mk | 37 | ||||
-rw-r--r-- | tools/workben/mempooltest.cxx | 18 |
4 files changed, 46 insertions, 40 deletions
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 <tools/solar.h> +#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 <tools/mempool.hxx> +#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..d97156c7f66c 100644 --- a/tools/workben/makefile.mk +++ b/tools/workben/makefile.mk @@ -26,8 +26,8 @@ #************************************************************************* PRJ = .. -PRJNAME = tl -TARGET = tldem +PRJNAME = tools +TARGET = workben LIBTARGET = NO TARGETTYPE = CUI ENABLE_EXCEPTIONS=TRUE @@ -37,10 +37,8 @@ ENABLE_EXCEPTIONS=TRUE OBJFILES = \ $(OBJ)$/solar.obj \ $(OBJ)$/urltest.obj \ - $(OBJ)$/inetmimetest.obj -# $(OBJ)$/demostor.obj \ -# $(OBJ)$/fstest.obj \ -# $(OBJ)$/tldem.obj \ + $(OBJ)$/inetmimetest.obj \ + $(OBJ)$/mempooltest.obj APP1TARGET = solar APP1OBJS = $(OBJ)$/solar.obj @@ -62,28 +60,9 @@ APP3TARGET = inetmimetest APP3OBJS = $(OBJ)$/inetmimetest.obj APP3STDLIBS = $(SALLIB) $(TOOLSLIB) -# APP3TARGET = tldem -# APP3OBJS = $(OBJ)$/tldem.obj -# .IF "$(GUI)" == "UNX" -# APP3STDLIBS = $(TOOLSLIB) -# .ELSE -# APP3STDLIBS = $(LB)$/itools.lib -# .ENDIF - -# APP4TARGET = demostor -# APP4OBJS = $(OBJ)$/demostor.obj -# .IF "$(GUI)" == "UNX" -# APP4STDLIBS = $(TOOLSLIB) $(VOSLIB) $(SALLIB) -# .ELSE -# APP4STDLIBS = $(LB)$/itools.lib $(VOSLIB) $(SALLIB) -# .ENDIF - -# APP5TARGET = fstest -# APP5OBJS = $(OBJ)$/fstest.obj -# .IF "$(GUI)" == "UNX" -# APP5STDLIBS = $(TOOLSLIB) $(VOSLIB) $(SALLIB) -# .ELSE -# APP5STDLIBS = $(LB)$/itools.lib $(VOSLIB) $(SALLIB) -# .ENDIF +APP4TARGET = mempooltest +APP4OBJS = $(OBJ)$/mempooltest.obj +APP4STDLIBS = $(TOOLSLIB) +APP4RPATH = UREBIN .INCLUDE: target.mk 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; +} |