1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Split off sqlite3DbFreeNN() from sqlite3DbFree() and use it in cases where

we know that the argument to be freed is never NULL.

FossilOrigin-Name: ad90e8bb5e47945607c8fb47b6ade8cfc52a9b684805cc40132629be0ecc14cc
This commit is contained in:
drh
2017-04-05 12:39:49 +00:00
parent ac48b751e2
commit dbd6a7dc06
12 changed files with 59 additions and 53 deletions

View File

@@ -474,11 +474,12 @@ static SQLITE_NOINLINE void measureAllocationSize(sqlite3 *db, void *p){
/*
** Free memory that might be associated with a particular database
** connection.
** connection. Calling sqlite3DbFree(D,X) for X==0 is a harmless no-op.
** The sqlite3DbFreeNN(D,X) version requires that X be non-NULL.
*/
void sqlite3DbFree(sqlite3 *db, void *p){
void sqlite3DbFreeNN(sqlite3 *db, void *p){
assert( db==0 || sqlite3_mutex_held(db->mutex) );
if( p==0 ) return;
assert( p!=0 );
if( db ){
if( db->pnBytesFreed ){
measureAllocationSize(db, p);
@@ -502,6 +503,10 @@ void sqlite3DbFree(sqlite3 *db, void *p){
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
sqlite3_free(p);
}
void sqlite3DbFree(sqlite3 *db, void *p){
assert( db==0 || sqlite3_mutex_held(db->mutex) );
if( p ) sqlite3DbFreeNN(db, p);
}
/*
** Change the size of an existing memory allocation