diff options
author | drh <drh@noemail.net> | 2014-08-23 20:25:53 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-08-23 20:25:53 +0000 |
commit | b50c65d561532c689a894112459be6e48f9ae366 (patch) | |
tree | 73a725bb7ed45634a9f26a798da17d1baeed4114 /src/malloc.c | |
parent | b4586f1254df07a7eccba2101ae4a95dfe2ca34b (diff) | |
download | sqlite-b50c65d561532c689a894112459be6e48f9ae366.tar.gz sqlite-b50c65d561532c689a894112459be6e48f9ae366.zip |
Faster implementation of the sqlite3ApiExit() routine.
FossilOrigin-Name: bd41d394d48516eb7d8ddc46abdcb427aa80173e
Diffstat (limited to 'src/malloc.c')
-rw-r--r-- | src/malloc.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/malloc.c b/src/malloc.c index 1b219604b..b4b70350f 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -761,6 +761,14 @@ void sqlite3SetString(char **pz, sqlite3 *db, const char *zFormat, ...){ *pz = z; } +/* +** Take actions at the end of an API call to indicate an OOM error +*/ +static SQLITE_NOINLINE int apiOomError(sqlite3 *db){ + db->mallocFailed = 0; + sqlite3Error(db, SQLITE_NOMEM); + return SQLITE_NOMEM; +} /* ** This function must be called before exiting any API function (i.e. @@ -781,10 +789,9 @@ int sqlite3ApiExit(sqlite3* db, int rc){ ** is unsafe, as is the call to sqlite3Error(). */ assert( !db || sqlite3_mutex_held(db->mutex) ); - if( db && (db->mallocFailed || rc==SQLITE_IOERR_NOMEM) ){ - sqlite3Error(db, SQLITE_NOMEM); - db->mallocFailed = 0; - rc = SQLITE_NOMEM; + if( db==0 ) return rc & 0xff; + if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){ + return apiOomError(db); } - return rc & (db ? db->errMask : 0xff); + return rc & db->errMask; } |