mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
Change the definition of SQLITE_CONFIG_PAGECACHE and
SQLITE_CONFIG_SCRATCH to omit the magic "+4" in the buffer size calculation. (CVS 5512) FossilOrigin-Name: e7ed0fe640a39053009eac52a7f055b121750e57
This commit is contained in:
10
src/malloc.c
10
src/malloc.c
@@ -12,7 +12,7 @@
|
||||
**
|
||||
** Memory allocation functions used throughout sqlite.
|
||||
**
|
||||
** $Id: malloc.c,v 1.31 2008/07/29 14:29:07 drh Exp $
|
||||
** $Id: malloc.c,v 1.32 2008/07/31 17:16:05 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <stdarg.h>
|
||||
@@ -115,6 +115,7 @@ int sqlite3MallocInit(void){
|
||||
if( sqlite3Config.pScratch && sqlite3Config.szScratch>=3000
|
||||
&& sqlite3Config.nScratch>0 ){
|
||||
int i;
|
||||
sqlite3Config.szScratch -= 4;
|
||||
mem0.aScratchFree = (u32*)&((char*)sqlite3Config.pScratch)
|
||||
[sqlite3Config.szScratch*sqlite3Config.nScratch];
|
||||
for(i=0; i<sqlite3Config.nScratch; i++){ mem0.aScratchFree[i] = i; }
|
||||
@@ -124,8 +125,13 @@ int sqlite3MallocInit(void){
|
||||
sqlite3Config.szScratch = 0;
|
||||
}
|
||||
if( sqlite3Config.pPage && sqlite3Config.szPage>=512
|
||||
&& sqlite3Config.nPage>0 ){
|
||||
&& sqlite3Config.nPage>1 ){
|
||||
int i;
|
||||
int overhead;
|
||||
int sz = sqlite3Config.szPage;
|
||||
int n = sqlite3Config.nPage;
|
||||
overhead = (4*n + sz - 1)/sz;
|
||||
sqlite3Config.nPage -= overhead;
|
||||
mem0.aPageFree = (u32*)&((char*)sqlite3Config.pPage)
|
||||
[sqlite3Config.szPage*sqlite3Config.nPage];
|
||||
for(i=0; i<sqlite3Config.nPage; i++){ mem0.aPageFree[i] = i; }
|
||||
|
||||
Reference in New Issue
Block a user