From ac84e70307408ae343a5ce794f076f2c8e0507a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Wed, 4 Jul 2012 09:40:11 +0000 Subject: [PATCH] Boost Jam now correctly reports its dangling string object count when displaying DEBUG_MEM messages independent of whether it is configured to use its hash-table OBJECT cache implementation or not. [SVN r79258] --- src/engine/object.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/engine/object.c b/src/engine/object.c index f1981d3bb..07298ad01 100644 --- a/src/engine/object.c +++ b/src/engine/object.c @@ -248,19 +248,22 @@ static void object_validate( OBJECT * obj ) OBJECT * object_new( char const * string ) { -#ifdef BJAM_NO_MEM_CACHE - int const len = strlen( string ) + 1; - struct hash_item * const m = (struct hash_item *)BJAM_MALLOC( sizeof( struct - hash_header) + len ); + ++strcount_in; - strtotal += len; - memcpy( m->data, string, len ); - m->header.magic = OBJECT_MAGIC; - return (OBJECT *)m->data; +#ifdef BJAM_NO_MEM_CACHE + { + int const len = strlen( string ) + 1; + struct hash_item * const m = (struct hash_item *)BJAM_MALLOC( sizeof( + struct hash_header ) + len ); + + strtotal += len; + memcpy( m->data, string, len ); + m->header.magic = OBJECT_MAGIC; + return (OBJECT *)m->data; + } #else if ( !strhash.data ) string_set_init( &strhash ); - ++strcount_in; return (OBJECT *)string_set_insert( &strhash, string ); #endif } @@ -374,8 +377,8 @@ void object_done() if ( DEBUG_MEM ) { printf( "%dK in strings\n", strtotal / 1024 ); - /* if ( strcount_in != strcount_out ) + if ( strcount_in != strcount_out ) printf( "--- %d strings of %d dangling\n", strcount_in - - strcount_out, strcount_in ); */ + strcount_out, strcount_in ); } }