/ Check-in [5a3140e4]
Login

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

Overview
Comment:Memory reallocation fix for the Win32 VFS for lsm1.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5a3140e4dedace6de4366a3c52e41b818b6d19f356fdab738c6605afc1b674fa
User & Date: mistachkin 2017-07-07 16:06:30
Context
2017-07-07
16:09
In lsmtest, use an empty string instead of ":memory:" when requesting a temporary database from SQLite. This prevents other test code from trying to unlink() ":memory:", which fails on win32. check-in: 281ad505 user: dan tags: trunk
16:07
Remove a block from the Win32 VFS for lsm1 that is now superfluous. check-in: db4a4140 user: mistachkin tags: trunk
16:06
Memory reallocation fix for the Win32 VFS for lsm1. check-in: 5a3140e4 user: mistachkin tags: trunk
16:00
Enhance the sqlite3VdbeMultiLoad() interface to automatically generate the OP_ResultRow opcode on PRAGMA implementations, for a small reduction in the library footprint. check-in: c46f0f07 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/lsm1/lsm_win32.c.

   249    249     int rc = LSM_OK;
   250    250     Win32File *pWin32File;
   251    251   
   252    252     pWin32File = lsmMallocZero(pEnv, sizeof(Win32File));
   253    253     if( pWin32File==0 ){
   254    254       rc = LSM_NOMEM_BKPT;
   255    255     }else{
   256         -    HANDLE hFile;
          256  +    HANDLE hFile = NULL;
   257    257   
   258    258       rc = win32Open(pEnv, zFile, flags, &hFile);
   259    259       if( rc==LSM_OK ){
   260    260         memset(&pWin32File->sysInfo, 0, sizeof(SYSTEM_INFO));
   261    261         GetSystemInfo(&pWin32File->sysInfo);
   262    262         pWin32File->pEnv = pEnv;
   263    263         pWin32File->zName = zFile;
................................................................................
   674    674       if( fileSize.QuadPart<nReq ){
   675    675         rc = win32Truncate(pWin32File->hShmFile, nReq);
   676    676         if( rc!=LSM_OK ){
   677    677           return rc;
   678    678         }
   679    679       }
   680    680   
   681         -    ahNew = (LPHANDLE)lsmRealloc(pWin32File->pEnv, pWin32File->ahShm,
   682         -                                 sizeof(LPHANDLE) * nNew);
          681  +    ahNew = (LPHANDLE)lsmMallocZero(pWin32File->pEnv, sizeof(LPHANDLE) * nNew);
   683    682       if( !ahNew ) return LSM_NOMEM_BKPT;
   684         -    apNew = (LPVOID *)lsmRealloc(pWin32File->pEnv, pWin32File->apShm,
   685         -                                 sizeof(LPVOID) * nNew);
          683  +    apNew = (LPVOID *)lsmMallocZero(pWin32File->pEnv, sizeof(LPVOID) * nNew);
   686    684       if( !apNew ){
   687    685         lsmFree(pWin32File->pEnv, ahNew);
   688    686         return LSM_NOMEM_BKPT;
   689    687       }
          688  +    memcpy(ahNew, pWin32File->ahShm, pWin32File->nShm);
          689  +    memcpy(apNew, pWin32File->apShm, pWin32File->nShm);
   690    690       for(i=pWin32File->nShm; i<nNew; i++){
   691    691         ahNew[i] = NULL;
   692    692         apNew[i] = NULL;
   693    693       }
          694  +    lsmFree(pWin32File->pEnv, pWin32File->ahShm);
   694    695       pWin32File->ahShm = ahNew;
          696  +    lsmFree(pWin32File->pEnv, pWin32File->apShm);
   695    697       pWin32File->apShm = apNew;
   696    698       pWin32File->nShm = nNew;
   697    699     }
   698    700   
   699    701     if( pWin32File->ahShm[iChunk]==NULL ){
   700    702       HANDLE hMap;
   701    703       assert( nReq<=0xFFFFFFFF );