diff options
author | dan <dan@noemail.net> | 2010-08-09 14:47:50 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2010-08-09 14:47:50 +0000 |
commit | ec561a351a08fb842caa2e65f4a3b601f4446793 (patch) | |
tree | 0c0cdb5e76d79ab28fc2cf606336427fb7c8d1c9 /src/test_malloc.c | |
parent | 007820d65d1ed51da24b8edfb9fb1855deb9de3c (diff) | |
download | sqlite-ec561a351a08fb842caa2e65f4a3b601f4446793.tar.gz sqlite-ec561a351a08fb842caa2e65f4a3b601f4446793.zip |
Change to tcl test infrastructure so that --malloctrace=1 works when sizeof(int)!=sizeof(void*).
FossilOrigin-Name: c3e771b3cf685f4237a2516ee7111849bf0ffb3f
Diffstat (limited to 'src/test_malloc.c')
-rw-r--r-- | src/test_malloc.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/test_malloc.c b/src/test_malloc.c index 3fa753b7e..08642c9fe 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -728,7 +728,10 @@ static int test_memdebug_settitle( return TCL_OK; } -#define MALLOC_LOG_FRAMES 10 +#define MALLOC_LOG_FRAMES 10 +#define MALLOC_LOG_KEYINTS ( \ + 10 * ((sizeof(int)>=sizeof(void*)) ? 1 : sizeof(void*)/sizeof(int)) \ +) static Tcl_HashTable aMallocLog; static int mallocLogEnabled = 0; @@ -745,8 +748,8 @@ static void test_memdebug_callback(int nByte, int nFrame, void **aFrame){ Tcl_HashEntry *pEntry; int isNew; - int aKey[MALLOC_LOG_FRAMES]; - int nKey = sizeof(int)*MALLOC_LOG_FRAMES; + int aKey[MALLOC_LOG_KEYINTS]; + int nKey = sizeof(int)*MALLOC_LOG_KEYINTS; memset(aKey, 0, nKey); if( (sizeof(void*)*nFrame)<nKey ){ @@ -781,7 +784,7 @@ static void test_memdebug_log_clear(void){ Tcl_Free((char *)pLog); } Tcl_DeleteHashTable(&aMallocLog); - Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_FRAMES); + Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS); } static int test_memdebug_log( @@ -804,7 +807,7 @@ static int test_memdebug_log( void (*xBacktrace)(int, int, void **)); sqlite3MemdebugBacktraceCallback(test_memdebug_callback); #endif - Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_FRAMES); + Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS); isInit = 1; } @@ -827,7 +830,7 @@ static int test_memdebug_log( Tcl_HashEntry *pEntry; Tcl_Obj *pRet = Tcl_NewObj(); - assert(sizeof(int)==sizeof(void*)); + assert(sizeof(Tcl_WideInt)>=sizeof(void*)); for( pEntry=Tcl_FirstHashEntry(&aMallocLog, &search); @@ -836,13 +839,13 @@ static int test_memdebug_log( ){ Tcl_Obj *apElem[MALLOC_LOG_FRAMES+2]; MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry); - int *aKey = (int *)Tcl_GetHashKey(&aMallocLog, pEntry); + Tcl_WideInt *aKey = (Tcl_WideInt *)Tcl_GetHashKey(&aMallocLog, pEntry); int ii; apElem[0] = Tcl_NewIntObj(pLog->nCall); apElem[1] = Tcl_NewIntObj(pLog->nByte); for(ii=0; ii<MALLOC_LOG_FRAMES; ii++){ - apElem[ii+2] = Tcl_NewIntObj(aKey[ii]); + apElem[ii+2] = Tcl_NewWideIntObj(aKey[ii]); } Tcl_ListObjAppendElement(interp, pRet, |