aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2016-01-05 03:39:25 +0000
committerdrh <drh@noemail.net>2016-01-05 03:39:25 +0000
commit0816905cddf7f545301f14abf6554e30ead246cc (patch)
treeb4c5c5f3c318acbf31fcb6c7663d71503996e642 /src
parent98486c046f1d245b5ffa1df8a850e349e4e25154 (diff)
downloadsqlite-0816905cddf7f545301f14abf6554e30ead246cc.tar.gz
sqlite-0816905cddf7f545301f14abf6554e30ead246cc.zip
Another attempt to get reuse of excess opcode array space working correctly
on all architectures and platforms. FossilOrigin-Name: 2f8583748abab1e15029d3a8693ba9a66c978c2b
Diffstat (limited to 'src')
-rw-r--r--src/vdbeaux.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index de7f48212..dbbb2a6cc 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -1851,19 +1851,24 @@ void sqlite3VdbeMakeReady(
/* zCsr will initially point to nFree bytes of unused space at the
** end of the opcode array, p->aOp. The computation of nFree is
** conservative - it might be smaller than the true number of free
- ** bytes, but never larger. nFree might be negative. But the allocation
- ** loop will still function correctly.
+ ** bytes, but never larger. nFree must be a multiple of 8 - it is
+ ** rounded down if is not.
*/
- zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */
- nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */
- if( nFree>0 ) memset(zCsr, 0, nFree);
+ n = ROUND8(sizeof(Op)*p->nOp); /* Bytes of opcode space used */
+ zCsr = &((u8*)p->aOp)[n]; /* Unused opcode space */
+ assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
+ nFree = ROUNDDOWN8(pParse->szOpAlloc - n); /* Bytes of unused space */
+ assert( nFree>=0 );
+ if( nFree>0 ){
+ memset(zCsr, 0, nFree);
+ assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) );
+ }
resolveP2Values(p, &nArg);
p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
if( pParse->explain && nMem<10 ){
nMem = 10;
}
- assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) );
p->expired = 0;
/* Memory for registers, parameters, cursor, etc, is allocated in two