diff options
author | drh <drh@noemail.net> | 2016-12-21 19:45:54 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-12-21 19:45:54 +0000 |
commit | a582b016983c5fc14971a8550f59c7e65fa5ae0d (patch) | |
tree | db096dacb260e2fdaf90003d5ba0f99dc3212d13 /src/btree.c | |
parent | f99dd359d00fd5af78d8ccb4b7c27fc82f578ddb (diff) | |
download | sqlite-a582b016983c5fc14971a8550f59c7e65fa5ae0d.tar.gz sqlite-a582b016983c5fc14971a8550f59c7e65fa5ae0d.zip |
Simplifications to the way UnpackedRecord objects are allocated. Smaller
and faster code that also fixes a subtle (currently unreachable) bug.
FossilOrigin-Name: f7ab01f254cd9d7006b8dec29adb234a671b8e6f
Diffstat (limited to 'src/btree.c')
-rw-r--r-- | src/btree.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/btree.c b/src/btree.c index 0cd1a2877..d2fd448f6 100644 --- a/src/btree.c +++ b/src/btree.c @@ -763,26 +763,23 @@ static int btreeMoveto( ){ int rc; /* Status code */ UnpackedRecord *pIdxKey; /* Unpacked index key */ - char aSpace[384]; /* Temp space for pIdxKey - to avoid a malloc */ - char *pFree = 0; if( pKey ){ assert( nKey==(i64)(int)nKey ); - pIdxKey = sqlite3VdbeAllocUnpackedRecord( - pCur->pKeyInfo, aSpace, sizeof(aSpace), &pFree - ); + pIdxKey = sqlite3VdbeAllocUnpackedRecord(pCur->pKeyInfo); if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT; sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey); if( pIdxKey->nField==0 ){ - sqlite3DbFree(pCur->pKeyInfo->db, pFree); - return SQLITE_CORRUPT_BKPT; + rc = SQLITE_CORRUPT_BKPT; + goto moveto_done; } }else{ pIdxKey = 0; } rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes); - if( pFree ){ - sqlite3DbFree(pCur->pKeyInfo->db, pFree); +moveto_done: + if( pIdxKey ){ + sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey); } return rc; } |