diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/malloc.c | 5 | ||||
-rw-r--r-- | src/mem1.c | 4 | ||||
-rw-r--r-- | src/mem3.c | 2 | ||||
-rw-r--r-- | src/mem5.c | 11 | ||||
-rw-r--r-- | src/status.c | 8 |
5 files changed, 15 insertions, 15 deletions
diff --git a/src/malloc.c b/src/malloc.c index f017e1bc0..7b52661a3 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -411,6 +411,7 @@ int sqlite3MallocSize(void *p){ return sqlite3GlobalConfig.m.xSize(p); } int sqlite3DbMallocSize(sqlite3 *db, void *p){ + assert( p!=0 ); if( db==0 || !isLookaside(db,p) ){ #if SQLITE_DEBUG if( db==0 ){ @@ -430,7 +431,7 @@ int sqlite3DbMallocSize(sqlite3 *db, void *p){ sqlite3_uint64 sqlite3_msize(void *p){ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); - return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p); + return p ? sqlite3GlobalConfig.m.xSize(p) : 0; } /* @@ -456,7 +457,7 @@ void sqlite3_free(void *p){ ** *db->pnBytesFreed. */ static SQLITE_NOINLINE void measureAllocationSize(sqlite3 *db, void *p){ - *db->pnBytesFreed += sqlite3DbMallocSize(db,p); + if( p ) *db->pnBytesFreed += sqlite3DbMallocSize(db,p); } /* diff --git a/src/mem1.c b/src/mem1.c index ec9a4e3a6..da6ae33e4 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -171,11 +171,11 @@ static void sqlite3MemFree(void *pPrior){ ** or xRealloc(). */ static int sqlite3MemSize(void *pPrior){ + assert( pPrior!=0 ); #ifdef SQLITE_MALLOCSIZE - return pPrior ? (int)SQLITE_MALLOCSIZE(pPrior) : 0; + return (int)SQLITE_MALLOCSIZE(pPrior); #else sqlite3_int64 *p; - if( pPrior==0 ) return 0; p = (sqlite3_int64*)pPrior; p--; return (int)p[0]; diff --git a/src/mem3.c b/src/mem3.c index 1a1b791f2..2de028daa 100644 --- a/src/mem3.c +++ b/src/mem3.c @@ -476,7 +476,7 @@ static void memsys3FreeUnsafe(void *pOld){ */ static int memsys3Size(void *p){ Mem3Block *pBlock; - if( p==0 ) return 0; + assert( p!=0 ); pBlock = (Mem3Block*)p; assert( (pBlock[-1].u.hdr.size4x&1)!=0 ); return (pBlock[-1].u.hdr.size4x&~3)*2 - 4; diff --git a/src/mem5.c b/src/mem5.c index 1479ddd0d..6bb24e544 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -200,12 +200,11 @@ static void memsys5Leave(void){ ** works for chunks that are currently checked out. */ static int memsys5Size(void *p){ - int iSize = 0; - if( p ){ - int i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom); - assert( i>=0 && i<mem5.nBlock ); - iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE)); - } + int iSize, i; + assert( p!=0 ); + i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom); + assert( i>=0 && i<mem5.nBlock ); + iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE)); return iSize; } diff --git a/src/status.c b/src/status.c index 4c41510a3..a7fddf060 100644 --- a/src/status.c +++ b/src/status.c @@ -255,10 +255,10 @@ int sqlite3_db_status( + pSchema->idxHash.count + pSchema->fkeyHash.count ); - nByte += sqlite3MallocSize(pSchema->tblHash.ht); - nByte += sqlite3MallocSize(pSchema->trigHash.ht); - nByte += sqlite3MallocSize(pSchema->idxHash.ht); - nByte += sqlite3MallocSize(pSchema->fkeyHash.ht); + nByte += sqlite3_msize(pSchema->tblHash.ht); + nByte += sqlite3_msize(pSchema->trigHash.ht); + nByte += sqlite3_msize(pSchema->idxHash.ht); + nByte += sqlite3_msize(pSchema->fkeyHash.ht); for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){ sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p)); |