/ Check-in [91b50f31]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Improvements to the xRandomness() method on the default windows VFS. Ticket #2615. (CVS 4374)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 91b50f31e35652a40d51f5d9bf22efce36d515e4
User & Date: drh 2007-09-03 13:06:12
Context
2007-09-03
15:03
Fix a problem in hash.c when replacing entries in tables configured with copyKey==0. (CVS 4375) check-in: a19d3a73 user: danielk1977 tags: trunk
13:06
Improvements to the xRandomness() method on the default windows VFS. Ticket #2615. (CVS 4374) check-in: 91b50f31 user: drh tags: trunk
12:34
Document the fact that xRandomness is only called once from the default VFS. Ticket #2614. (CVS 4373) check-in: e89d4131 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

  1417   1417   #endif
  1418   1418   
  1419   1419   
  1420   1420   /*
  1421   1421   ** Write up to nBuf bytes of randomness into zBuf.
  1422   1422   */
  1423   1423   static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
  1424         -  if( sizeof(LPSYSTEMTIME)>=nBuf ){
  1425         -    GetSystemTime((LPSYSTEMTIME)zBuf);
  1426         -    return sizeof(LPSYSTEMTIME);
  1427         -  }else{
  1428         -    return 0;
         1424  +  int n = 0;
         1425  +  if( sizeof(LPSYSTEMTIME)<=nBuf-n ){
         1426  +    SYSTEMTIME x;
         1427  +    GetSystemTime(&x);
         1428  +    memcpy(&zBuf[n], &x, sizeof(x));
         1429  +    n += sizeof(x);
         1430  +  }
         1431  +  if( sizeof(DWORD)<=nBuf-n ){
         1432  +    DWORD pid = GetCurrentProcessId();
         1433  +    memcpy(&zBuf[n], &pid, sizeof(pid));
         1434  +    n += sizeof(pid);
         1435  +  }
         1436  +  if( sizeof(DWORD)<=nBuf-n ){
         1437  +    DWORD cnt = GetTickCount();
         1438  +    memcpy(&zBuf[n], &cnt, sizeof(cnt));
         1439  +    n += sizeof(cnt);
         1440  +  }
         1441  +  if( sizeof(LARGE_INTEGER)<=nBuf-n ){
         1442  +    LARGE_INTEGER i;
         1443  +    QueryPerformanceCounter(&i);
         1444  +    memcpy(&zBuf[n], &i, sizeof(i));
         1445  +    n += sizeof(i);
  1429   1446     }
         1447  +  return n;
  1430   1448   }
  1431   1449   
  1432   1450   
  1433   1451   /*
  1434   1452   ** Sleep for a little while.  Return the amount of time slept.
  1435   1453   */
  1436   1454   static int winSleep(sqlite3_vfs *pVfs, int microsec){