diff options
author | drh <drh@noemail.net> | 2010-08-20 09:14:13 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-08-20 09:14:13 +0000 |
commit | c8f503a8d33e5e100a4f53d26f31c7e4e8f78592 (patch) | |
tree | 584d8dd11b95dd26ace6998d89789c2648450d06 /src | |
parent | 5ad723f4124f774172c94f91aae770ec14122987 (diff) | |
download | sqlite-c8f503a8d33e5e100a4f53d26f31c7e4e8f78592.tar.gz sqlite-c8f503a8d33e5e100a4f53d26f31c7e4e8f78592.zip |
Fix the sqlite3_release_memory() interface so that it does not attempt
to free SQLITE_CONFIG_PAGECACHE memory.
FossilOrigin-Name: 0426cd62d5ef2bd09570835c78f8fc3bcb7cdd49
Diffstat (limited to 'src')
-rw-r--r-- | src/pcache1.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/pcache1.c b/src/pcache1.c index a9ee63e7c..f9927b894 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -200,6 +200,25 @@ static void pcache1Free(void *p){ } } +#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT +/* +** Return the size of a pache allocation +*/ +static int pcache1MemSize(void *p){ + assert( sqlite3_mutex_held(pcache1.mutex) ); + if( p>=pcache1.pStart && p<pcache1.pEnd ){ + return pcache1.szSlot; + }else{ + int iSize; + assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) ); + sqlite3MemdebugSetType(p, MEMTYPE_HEAP); + iSize = sqlite3MallocSize(p); + sqlite3MemdebugSetType(p, MEMTYPE_PCACHE); + return iSize; + } +} +#endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */ + /* ** Allocate a new page object initially associated with cache pCache. */ @@ -748,7 +767,7 @@ int sqlite3PcacheReleaseMemory(int nReq){ PgHdr1 *p; pcache1EnterMutex(); while( (nReq<0 || nFree<nReq) && (p=pcache1.pLruTail) ){ - nFree += sqlite3MallocSize(PGHDR1_TO_PAGE(p)); + nFree += pcache1MemSize(PGHDR1_TO_PAGE(p)); pcache1PinPage(p); pcache1RemoveFromHash(p); pcache1FreePage(p); |