mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Change to tcl test infrastructure so that --malloctrace=1 works when sizeof(int)!=sizeof(void*).
FossilOrigin-Name: c3e771b3cf685f4237a2516ee7111849bf0ffb3f
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user