mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Combine two malloc calls in vdbesort.c.
FossilOrigin-Name: cf48ad8353e28339d00f448bb729e10a7f2aad72
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
||||
C Reduce\sthe\snumber\sof\smalloc()\scalls\smade\swhen\screating\san\sindex\son\smore\sthan\s2\scolumns.
|
||||
D 2011-09-02T15:41:33.781
|
||||
C Combine\stwo\smalloc\scalls\sin\svdbesort.c.
|
||||
D 2011-09-02T18:03:16.975
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in d314143fa6be24828021d3f583ad37d9afdce505
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -124,7 +124,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
||||
F src/backup.c 28a4fe55327ff708bfaf9d4326d02686f7a553c3
|
||||
F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef
|
||||
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
|
||||
F src/btree.c bc2099e7d3c22c52b2c54349b9c07c04f2a810d0
|
||||
F src/btree.c dc3f244447fd5aade08f66d475e2a6316bbef4e7
|
||||
F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce
|
||||
F src/btreeInt.h 67978c014fa4f7cc874032dd3aacadd8db656bc3
|
||||
F src/build.c dc367138cb3625e6d42b389e05d7267aece5753c
|
||||
@@ -245,7 +245,7 @@ F src/vdbeapi.c 11dc47987abacb76ad016dcf5abc0dc422482a98
|
||||
F src/vdbeaux.c e58acbc5ea3823922a0cd8fa21f94f39af51ee88
|
||||
F src/vdbeblob.c f024f0bf420f36b070143c32b15cc7287341ffd3
|
||||
F src/vdbemem.c 5e6effb96dd53d233361cbfaa3f0a43b9af689e9
|
||||
F src/vdbesort.c a49d44498cc19af9bdbdc8e9fa882dd26cc17066
|
||||
F src/vdbesort.c b56437b8b3a0a17a2b110d37633dc9217c72fd60
|
||||
F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114
|
||||
F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582
|
||||
F src/wal.c 3154756177d6219e233d84291d5b05f4e06ff5e9
|
||||
@@ -961,7 +961,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
|
||||
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
|
||||
P 71075673c625f243969c3f34c73f28f378924007
|
||||
R 16433222f8a97f40a1aa6bc60c6c3db0
|
||||
P 065b0c9858da0ebb41722f3c56bdaf62f28b2f2c
|
||||
R 06bb7ef7ee2f3a8f904497ea31ee4edb
|
||||
U dan
|
||||
Z 8c008bdf93f87673bd214d386e7f6cf5
|
||||
Z ad89820409358feeee63c15f85c9298f
|
||||
|
@@ -1 +1 @@
|
||||
065b0c9858da0ebb41722f3c56bdaf62f28b2f2c
|
||||
cf48ad8353e28339d00f448bb729e10a7f2aad72
|
@@ -7288,13 +7288,7 @@ int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){
|
||||
BtShared *pBt = p->pBt;
|
||||
int rc;
|
||||
sqlite3BtreeEnter(p);
|
||||
if( (pBt->openFlags&BTREE_SINGLE) ){
|
||||
pBt->nPage = 0;
|
||||
sqlite3PagerTruncateImage(pBt->pPager, 1);
|
||||
rc = newDatabase(pBt);
|
||||
}else{
|
||||
rc = btreeDropTable(p, iTable, piMoved);
|
||||
}
|
||||
sqlite3BtreeLeave(p);
|
||||
return rc;
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ typedef struct SorterRecord SorterRecord;
|
||||
** being merged (rounded up to the next power of 2).
|
||||
*/
|
||||
struct VdbeSorter {
|
||||
int nInMemory; /* Current size of b-tree contents as PMA */
|
||||
int nInMemory; /* Current size of pRecord list as PMA */
|
||||
int nTree; /* Used size of aTree/aIter (power of 2) */
|
||||
VdbeSorterIter *aIter; /* Array of iterators to merge */
|
||||
int *aTree; /* Current state of incremental merge */
|
||||
@@ -422,7 +422,6 @@ static void vdbeSorterRecordFree(sqlite3 *db, SorterRecord *pRecord){
|
||||
SorterRecord *pNext;
|
||||
for(p=pRecord; p; p=pNext){
|
||||
pNext = p->pNext;
|
||||
sqlite3DbFree(db, p->pVal);
|
||||
sqlite3DbFree(db, p);
|
||||
}
|
||||
}
|
||||
@@ -630,7 +629,6 @@ static int vdbeSorterListToPMA(sqlite3 *db, VdbeCursor *pCsr){
|
||||
iOff += p->nVal;
|
||||
}
|
||||
|
||||
sqlite3DbFree(db, p->pVal);
|
||||
sqlite3DbFree(db, p);
|
||||
}
|
||||
|
||||
@@ -657,28 +655,21 @@ int sqlite3VdbeSorterWrite(
|
||||
Mem *pVal /* Memory cell containing record */
|
||||
){
|
||||
VdbeSorter *pSorter = pCsr->pSorter;
|
||||
int rc;
|
||||
SorterRecord *pNew;
|
||||
int rc = SQLITE_OK; /* Return Code */
|
||||
SorterRecord *pNew; /* New list element */
|
||||
|
||||
assert( pSorter );
|
||||
pSorter->nInMemory += sqlite3VarintLen(pVal->n) + pVal->n;
|
||||
|
||||
pNew = (SorterRecord *)sqlite3DbMallocZero(db, sizeof(SorterRecord));
|
||||
pNew = (SorterRecord *)sqlite3DbMallocRaw(db, pVal->n + sizeof(SorterRecord));
|
||||
if( pNew==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}else{
|
||||
rc = sqlite3VdbeMemMakeWriteable(pVal);
|
||||
if( rc==SQLITE_OK ){
|
||||
pNew->pVal = pVal->z;
|
||||
pNew->pVal = (void *)&pNew[1];
|
||||
memcpy(pNew->pVal, pVal->z, pVal->n);
|
||||
pNew->nVal = pVal->n;
|
||||
pVal->zMalloc = 0;
|
||||
sqlite3VdbeMemSetNull(pVal);
|
||||
pNew->pNext = pSorter->pRecord;
|
||||
pSorter->pRecord = pNew;
|
||||
}else{
|
||||
sqlite3DbFree(db, pNew);
|
||||
rc = SQLITE_NOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
/* See if the contents of the sorter should now be written out. They
|
||||
|
Reference in New Issue
Block a user