/ Check-in [c3e771b3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change to tcl test infrastructure so that --malloctrace=1 works when sizeof(int)!=sizeof(void*).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: c3e771b3cf685f4237a2516ee7111849bf0ffb3f
User & Date: dan 2010-08-09 14:47:50
Context
2010-08-09
16:12
Fix a memory leak in test_journal.c causing tests to fail. check-in: f229487c user: dan tags: experimental
14:47
Change to tcl test infrastructure so that --malloctrace=1 works when sizeof(int)!=sizeof(void*). check-in: c3e771b3 user: dan tags: experimental
07:51
Fix a problem causing the return code of an xSync call to be ignored in wal.c. check-in: f1b2b5f9 user: dan tags: experimental
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_malloc.c.

   724    724       extern int sqlite3MemdebugSettitle(const char*);
   725    725       sqlite3MemdebugSettitle(zTitle);
   726    726     }
   727    727   #endif
   728    728     return TCL_OK;
   729    729   }
   730    730   
   731         -#define MALLOC_LOG_FRAMES 10 
          731  +#define MALLOC_LOG_FRAMES  10 
          732  +#define MALLOC_LOG_KEYINTS (                                              \
          733  +    10 * ((sizeof(int)>=sizeof(void*)) ? 1 : sizeof(void*)/sizeof(int))   \
          734  +)
   732    735   static Tcl_HashTable aMallocLog;
   733    736   static int mallocLogEnabled = 0;
   734    737   
   735    738   typedef struct MallocLog MallocLog;
   736    739   struct MallocLog {
   737    740     int nCall;
   738    741     int nByte;
................................................................................
   741    744   #ifdef SQLITE_MEMDEBUG
   742    745   static void test_memdebug_callback(int nByte, int nFrame, void **aFrame){
   743    746     if( mallocLogEnabled ){
   744    747       MallocLog *pLog;
   745    748       Tcl_HashEntry *pEntry;
   746    749       int isNew;
   747    750   
   748         -    int aKey[MALLOC_LOG_FRAMES];
   749         -    int nKey = sizeof(int)*MALLOC_LOG_FRAMES;
          751  +    int aKey[MALLOC_LOG_KEYINTS];
          752  +    int nKey = sizeof(int)*MALLOC_LOG_KEYINTS;
   750    753   
   751    754       memset(aKey, 0, nKey);
   752    755       if( (sizeof(void*)*nFrame)<nKey ){
   753    756         nKey = nFrame*sizeof(void*);
   754    757       }
   755    758       memcpy(aKey, aFrame, nKey);
   756    759   
................................................................................
   777    780       pEntry;
   778    781       pEntry=Tcl_NextHashEntry(&search)
   779    782     ){
   780    783       MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry);
   781    784       Tcl_Free((char *)pLog);
   782    785     }
   783    786     Tcl_DeleteHashTable(&aMallocLog);
   784         -  Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_FRAMES);
          787  +  Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS);
   785    788   }
   786    789   
   787    790   static int test_memdebug_log(
   788    791     void * clientData,
   789    792     Tcl_Interp *interp,
   790    793     int objc,
   791    794     Tcl_Obj *CONST objv[]
................................................................................
   800    803   
   801    804     if( !isInit ){
   802    805   #ifdef SQLITE_MEMDEBUG
   803    806       extern void sqlite3MemdebugBacktraceCallback(
   804    807           void (*xBacktrace)(int, int, void **));
   805    808       sqlite3MemdebugBacktraceCallback(test_memdebug_callback);
   806    809   #endif
   807         -    Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_FRAMES);
          810  +    Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS);
   808    811       isInit = 1;
   809    812     }
   810    813   
   811    814     if( objc<2 ){
   812    815       Tcl_WrongNumArgs(interp, 1, objv, "SUB-COMMAND ...");
   813    816     }
   814    817     if( Tcl_GetIndexFromObj(interp, objv[1], MB_strs, "sub-command", 0, &iSub) ){
................................................................................
   823    826         mallocLogEnabled = 0;
   824    827         break;
   825    828       case MB_LOG_DUMP: {
   826    829         Tcl_HashSearch search;
   827    830         Tcl_HashEntry *pEntry;
   828    831         Tcl_Obj *pRet = Tcl_NewObj();
   829    832   
   830         -      assert(sizeof(int)==sizeof(void*));
          833  +      assert(sizeof(Tcl_WideInt)>=sizeof(void*));
   831    834   
   832    835         for(
   833    836           pEntry=Tcl_FirstHashEntry(&aMallocLog, &search);
   834    837           pEntry;
   835    838           pEntry=Tcl_NextHashEntry(&search)
   836    839         ){
   837    840           Tcl_Obj *apElem[MALLOC_LOG_FRAMES+2];
   838    841           MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry);
   839         -        int *aKey = (int *)Tcl_GetHashKey(&aMallocLog, pEntry);
          842  +        Tcl_WideInt *aKey = (Tcl_WideInt *)Tcl_GetHashKey(&aMallocLog, pEntry);
   840    843           int ii;
   841    844     
   842    845           apElem[0] = Tcl_NewIntObj(pLog->nCall);
   843    846           apElem[1] = Tcl_NewIntObj(pLog->nByte);
   844    847           for(ii=0; ii<MALLOC_LOG_FRAMES; ii++){
   845         -          apElem[ii+2] = Tcl_NewIntObj(aKey[ii]);
          848  +          apElem[ii+2] = Tcl_NewWideIntObj(aKey[ii]);
   846    849           }
   847    850   
   848    851           Tcl_ListObjAppendElement(interp, pRet,
   849    852               Tcl_NewListObj(MALLOC_LOG_FRAMES+2, apElem)
   850    853           );
   851    854         }
   852    855