/ Check-in [bdc45ba7]
Login

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

Overview
Comment:Force 8-byte memory alignment on memory allocated for VDBE cursors.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bdc45ba77fb77771c8ff46b8d6c2dd29e6d3b019
User & Date: drh 2009-11-13 17:05:54
Context
2009-11-13
19:43
Simplify the OPFLG processing logic in the VDBE for a speed boost in the VDBE processing loop and a reduction in code size. check-in: 3352b3eb user: drh tags: trunk
17:36
Start reworking fts3 code to match the rest of SQLite (code conventions, malloc-failure handling etc.). check-in: 30a92f11 user: dan tags: fts3-refactor
17:05
Force 8-byte memory alignment on memory allocated for VDBE cursors. check-in: bdc45ba7 user: drh tags: trunk
10:04
Changes to test_intarray.c so that it build with SQLITE_OMIT_VIRTUALTABLE. Added testcase() macros to expr.c. check-in: f0599d28 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  3348   3348   **
  3349   3349   ** This interfaces is needed so that users of cursors can preallocate
  3350   3350   ** sufficient storage to hold a cursor.  The BtCursor object is opaque
  3351   3351   ** to users so they cannot do the sizeof() themselves - they must call
  3352   3352   ** this routine.
  3353   3353   */
  3354   3354   int sqlite3BtreeCursorSize(void){
  3355         -  return sizeof(BtCursor);
         3355  +  return ROUND8(sizeof(BtCursor));
  3356   3356   }
  3357   3357   
  3358   3358   /*
  3359   3359   ** Set the cached rowid value of every cursor in the same database file
  3360   3360   ** as pCur and having the same root page number as pCur.  The value is
  3361   3361   ** set to iRowid.
  3362   3362   **

Changes to src/vdbe.c.

   217    217     ** cursor 1 is managed by memory cell (p->nMem-1), etc.
   218    218     */
   219    219     Mem *pMem = &p->aMem[p->nMem-iCur];
   220    220   
   221    221     int nByte;
   222    222     VdbeCursor *pCx = 0;
   223    223     nByte = 
   224         -      sizeof(VdbeCursor) + 
          224  +      ROUND8(sizeof(VdbeCursor)) + 
   225    225         (isBtreeCursor?sqlite3BtreeCursorSize():0) + 
   226    226         2*nField*sizeof(u32);
   227    227   
   228    228     assert( iCur<p->nCursor );
   229    229     if( p->apCsr[iCur] ){
   230    230       sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
   231    231       p->apCsr[iCur] = 0;
   232    232     }
   233    233     if( SQLITE_OK==sqlite3VdbeMemGrow(pMem, nByte, 0) ){
   234    234       p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
   235         -    memset(pMem->z, 0, nByte);
          235  +    memset(pCx, 0, nByte);
   236    236       pCx->iDb = iDb;
   237    237       pCx->nField = nField;
   238    238       if( nField ){
   239         -      pCx->aType = (u32 *)&pMem->z[sizeof(VdbeCursor)];
          239  +      pCx->aType = (u32 *)&pMem->z[ROUND8(sizeof(VdbeCursor))];
   240    240       }
   241    241       if( isBtreeCursor ){
   242    242         pCx->pCursor = (BtCursor*)
   243         -          &pMem->z[sizeof(VdbeCursor)+2*nField*sizeof(u32)];
          243  +          &pMem->z[ROUND8(sizeof(VdbeCursor))+2*nField*sizeof(u32)];
   244    244       }
   245    245     }
   246    246     return pCx;
   247    247   }
   248    248   
   249    249   /*
   250    250   ** Try to convert a value into a numeric representation if we can