/ Check-in [04211e6a]
Login

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

Overview
Comment:Adjust memory size computations to avoid a conditional that is always false on 64-bit systems. (CVS 6942)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:04211e6af9cdd3e7f19b458c72b722f8f8584245
User & Date: drh 2009-07-25 17:42:22
Context
2009-07-25
19:31
Remove obsolete assert and testcase macros related to ticket #2565 (CVS 6943) check-in: f0024b31 user: drh tags: trunk
17:42
Adjust memory size computations to avoid a conditional that is always false on 64-bit systems. (CVS 6942) check-in: 04211e6a user: drh tags: trunk
17:39
Change an unreachable condition in PagerSharedLock to a NEVER(...). Add an assert to pager_error() to show that it is never called to put an in-memory pager to the error-state. (CVS 6941) check-in: 1d931f77 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used for creating, destroying, and populating
    13     13   ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)  Prior
    14     14   ** to version 2.8.7, all this code was combined into the vdbe.c source file.
    15     15   ** But that file was getting too big so this subroutines were split out.
    16     16   **
    17         -** $Id: vdbeaux.c,v 1.478 2009/07/24 17:58:53 danielk1977 Exp $
           17  +** $Id: vdbeaux.c,v 1.479 2009/07/25 17:42:22 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "vdbeInt.h"
    21     21   
    22     22   
    23     23   
    24     24   /*
................................................................................
  1060   1060     u8 **ppFrom,         /* IN/OUT: Allocate from *ppFrom */
  1061   1061     u8 *pEnd,            /* Pointer to 1 byte past the end of *ppFrom buffer */
  1062   1062     int *pnByte          /* If allocation cannot be made, increment *pnByte */
  1063   1063   ){
  1064   1064     assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
  1065   1065     if( (*(void**)pp)==0 ){
  1066   1066       nByte = ROUND8(nByte);
  1067         -    if( (pEnd - *ppFrom)>=nByte ){
         1067  +    if( &(*ppFrom)[nByte] <= pEnd ){
  1068   1068         *(void**)pp = (void *)*ppFrom;
  1069   1069         *ppFrom += nByte;
  1070   1070       }else{
  1071   1071         *pnByte += nByte;
  1072   1072       }
  1073   1073     }
  1074   1074   }
................................................................................
  1131   1131       u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];
  1132   1132       int nByte;
  1133   1133       int nArg;       /* Maximum number of args passed to a user function. */
  1134   1134       resolveP2Values(p, &nArg);
  1135   1135       if( isExplain && nMem<10 ){
  1136   1136         nMem = 10;
  1137   1137       }
         1138  +    memset(zCsr, 0, zEnd-zCsr);
  1138   1139       zCsr += (zCsr - (u8*)0)&7;
  1139   1140       assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
  1140         -    if( zEnd<zCsr ) zEnd = zCsr;
  1141   1141   
  1142   1142       do {
  1143         -      memset(zCsr, 0, zEnd-zCsr);
  1144   1143         nByte = 0;
  1145   1144         allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
  1146   1145         allocSpace((char*)&p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
  1147   1146         allocSpace((char*)&p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
  1148   1147         allocSpace((char*)&p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
  1149   1148         allocSpace((char*)&p->apCsr, 
  1150   1149                    nCursor*sizeof(VdbeCursor*), &zCsr, zEnd, &nByte
  1151   1150         );
  1152   1151         if( nByte ){
  1153         -        p->pFree = sqlite3DbMallocRaw(db, nByte);
         1152  +        p->pFree = sqlite3DbMallocZero(db, nByte);
  1154   1153         }
  1155   1154         zCsr = p->pFree;
  1156   1155         zEnd = &zCsr[nByte];
  1157   1156       }while( nByte && !db->mallocFailed );
  1158   1157   
  1159   1158       p->nCursor = (u16)nCursor;
  1160   1159       if( p->aVar ){