/ Check-in [fbf8c382]
Login

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

Overview
Comment:Add more assert() statements and fix compilation issues when the Win32 native heap is not enabled.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | win32heap
Files: files | file ages | folders
SHA1: fbf8c3828327d19bbce0d7f6735e7577abfd54b3
User & Date: mistachkin 2013-11-08 20:10:57
Context
2013-11-09
21:10
Furhter cleanup of the winGetTempname function. check-in: 674de36b user: mistachkin tags: win32heap
2013-11-08
20:10
Add more assert() statements and fix compilation issues when the Win32 native heap is not enabled. check-in: fbf8c382 user: mistachkin tags: win32heap
19:51
Disable use of HeapCompact on Windows CE as it is not available on all versions. check-in: e9694b87 user: mistachkin tags: win32heap
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  1085   1085     }
  1086   1086     for(i++; i<ArraySize(aSyscall); i++){
  1087   1087       if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;
  1088   1088     }
  1089   1089     return 0;
  1090   1090   }
  1091   1091   
         1092  +#ifdef SQLITE_WIN32_MALLOC
  1092   1093   /*
  1093   1094   ** If a Win32 native heap has been configured, this function will attempt to
  1094   1095   ** compact it.  Upon success, SQLITE_OK will be returned.  Upon failure, one
  1095   1096   ** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned.  The
  1096   1097   ** "pnLargest" argument, if non-zero, will be used to return the size of the
  1097   1098   ** largest committed free block in the heap, in bytes.
  1098   1099   */
................................................................................
  1140   1141     int rc;
  1141   1142     MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
  1142   1143     MUTEX_LOGIC( sqlite3_mutex *pMem; )    /* The memsys static mutex */
  1143   1144     MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
  1144   1145     MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); )
  1145   1146     sqlite3_mutex_enter(pMaster);
  1146   1147     sqlite3_mutex_enter(pMem);
  1147         -  if( winMemGetOwned() && sqlite3_memory_used()==0 ){
         1148  +  winMemAssertMagic();
         1149  +  if( winMemGetHeap()!=NULL && winMemGetOwned() && sqlite3_memory_used()==0 ){
  1148   1150       /*
  1149   1151       ** At this point, there should be no outstanding memory allocations on
  1150   1152       ** the heap.  Also, since both the master and memsys locks are currently
  1151   1153       ** being held by us, no other function (i.e. from another thread) should
  1152   1154       ** be able to even access the heap.  Attempt to destroy and recreate our
  1153   1155       ** isolated Win32 native heap now.
  1154   1156       */
         1157  +    assert( winMemGetHeap()!=NULL );
         1158  +    assert( winMemGetOwned() );
         1159  +    assert( sqlite3_memory_used()==0 );
  1155   1160       winMemShutdown(winMemGetDataPtr());
         1161  +    assert( winMemGetHeap()==NULL );
         1162  +    assert( !winMemGetOwned() );
         1163  +    assert( sqlite3_memory_used()==0 );
  1156   1164       rc = winMemInit(winMemGetDataPtr());
         1165  +    assert( rc!=SQLITE_OK || winMemGetHeap()!=NULL );
         1166  +    assert( rc!=SQLITE_OK || winMemGetOwned() );
         1167  +    assert( rc!=SQLITE_OK || sqlite3_memory_used()==0 );
  1157   1168     }else{
  1158   1169       /*
  1159   1170       ** The Win32 native heap cannot be modified because it may be in use.
  1160   1171       */
  1161   1172       rc = SQLITE_BUSY;
  1162   1173     }
  1163   1174     sqlite3_mutex_leave(pMem);
  1164   1175     sqlite3_mutex_leave(pMaster);
  1165   1176     return rc;
  1166   1177   }
         1178  +#endif /* SQLITE_WIN32_MALLOC */
  1167   1179   
  1168   1180   /*
  1169   1181   ** This function outputs the specified (ANSI) string to the Win32 debugger
  1170   1182   ** (if available).
  1171   1183   */
  1172   1184   
  1173   1185   void sqlite3_win32_write_debug(const char *zBuf, int nBuf){