From 6d4a2e8f5153eefcada061d346aa5d852f2500ee Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 22 Aug 2009 04:00:54 +0000 Subject: Pretty much just removed the debugging from SharedCore, it wasn't at fault, and it passed many more valgrind tests. --- src/sharedcore.cpp | 67 ------------------------------------------------------ src/sharedcore.h | 37 ++---------------------------- 2 files changed, 2 insertions(+), 102 deletions(-) (limited to 'src') diff --git a/src/sharedcore.cpp b/src/sharedcore.cpp index 24d8972..6333335 100644 --- a/src/sharedcore.cpp +++ b/src/sharedcore.cpp @@ -7,70 +7,3 @@ #include "bu/sharedcore.h" -void hardlog(const char *fmt, ...) -{ - va_list ap; - va_start( ap, fmt ); - - FILE *fh = fopen("sharedcore.log", "ab"); - vfprintf( fh, fmt, ap ); - va_end( ap ); - fclose( fh ); -} - -int iDepth = 0; - -void fncin( void *base, const char *fn, void *core, int *iRefCount, int params, ... ) -{ - va_list ap; - va_start( ap, params ); - - FILE *fh = fopen("sharedcore.log", "ab"); - fprintf( fh, "%08X: ", base ); - for( int j = 0; j < iDepth; j++ ) - fprintf( fh, " " ); - fprintf( fh, "%s(", fn ); - for( int j = 0; j < params; j++ ) - if( j == 0 ) - fprintf( fh, " %08X", va_arg( ap, void * ) ); - else - fprintf( fh, ", %08X", va_arg( ap, void * ) ); - if( params > 0 ) - fprintf( fh, " )"); - else - fprintf( fh, ")"); - - fprintf( fh, " [%08X / %08X] (%d)\n", core, iRefCount, rc ); - va_end( ap ); - fclose( fh ); - - iDepth++; -} - -void fncout( void *base, const char *fn, void *core, int *iRefCount, int params, ... ) -{ - va_list ap; - va_start( ap, params ); - - iDepth--; - - FILE *fh = fopen("sharedcore.log", "ab"); - fprintf( fh, "%08X: ", base ); - for( int j = 0; j < iDepth; j++ ) - fprintf( fh, " " ); - fprintf( fh, "%s(", fn ); - for( int j = 0; j < params; j++ ) - if( j == 0 ) - fprintf( fh, " %08X", va_arg( ap, void * ) ); - else - fprintf( fh, ", %08X", va_arg( ap, void * ) ); - if( params > 0 ) - fprintf( fh, " )"); - else - fprintf( fh, ")"); - - fprintf( fh, " [%08X / %08X] (%d)\n", core, iRefCount, rc ); - va_end( ap ); - fclose( fh ); -} - diff --git a/src/sharedcore.h b/src/sharedcore.h index 7960fa2..046e973 100644 --- a/src/sharedcore.h +++ b/src/sharedcore.h @@ -13,17 +13,6 @@ #include #include -void hardlog(const char *fmt, ...); - -void fncin( void *base, const char *fn, void *core, int *refcnt, int params, ... ); -void fncout( void *base, const char *fn, void *core, int *refcnt, int params, ... ); - - -#define fin( count, ... ) fncin( (void *)this, __FUNCTION__, core, iRefCount, count, ##__VA_ARGS__ ) -#define fout( count, ... ) fncout( (void *)this, __FUNCTION__, core, iRefCount, count, ##__VA_ARGS__ ) - -#define rc ((iRefCount==NULL)?(-1):(*iRefCount)) - namespace Bu { template @@ -35,33 +24,25 @@ namespace Bu core( NULL ), iRefCount( NULL ) { - fin( 0 ); core = _allocateCore(); iRefCount = new int(1); - fout( 0 ); } SharedCore( const _SharedType &rSrc ) : core( NULL ), iRefCount( NULL ) { - fin( 1, &rSrc ); _softCopy( rSrc ); - fout( 1, &rSrc ); } virtual ~SharedCore() { - fin( 0 ); _deref(); - fout( 0 ); } SharedCore &operator=( const SharedCore &rhs ) { - fin( 1, &rhs ); _softCopy( rhs ); - fout( 1, &rhs ); return *this; } @@ -74,43 +55,34 @@ namespace Bu Core *core; void _hardCopy() { - fin( 0 ); if( !core || !iRefCount ) - { fout( 0 ); return; } + return; if( (*iRefCount) == 1 ) - { fout( 0 ); return; } + return; Core *copy = _copyCore( core ); _deref(); core = copy; iRefCount = new int( 1 ); - fout( 0 ); } virtual Core *_allocateCore() { - fin( 0 ); - fout( 0 ); return new Core(); } virtual Core *_copyCore( Core *pSrc ) { - fin( 0 ); - fout( 0 ); return new Core( *pSrc ); } virtual void _deallocateCore( Core *pSrc ) { - fin( 0 ); - fout( 0 ); delete pSrc; } private: void _deref() { - fin( 0 ); if( (--(*iRefCount)) == 0 ) { _deallocateCore( core ); @@ -118,26 +90,21 @@ namespace Bu } core = NULL; iRefCount = NULL; - fout( 0 ); } void _incRefCount() { - fin( 0 ); if( iRefCount && core ) ++(*iRefCount); - fout( 0 ); } void _softCopy( const _SharedType &rSrc ) { - fin( 1, &rSrc ); if( core ) _deref(); core = rSrc.core; iRefCount = rSrc.iRefCount; _incRefCount(); - fout( 1, &rSrc ); } int *iRefCount; -- cgit v1.2.3