/* If the first argument, db, is not NULL and a malloc() error has occurred, then the connection error-code (the value returned by sqlite3_errcode()) is set to SQLITE_NOMEM.  */
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int)
/* If the first argument, db, is not NULL and a malloc() error has occurred, then the connection error-code (the value returned by sqlite3_errcode()) is set to SQLITE_NOMEM.  */
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int)
{
  assert( !db || sqlite3_mutex_held(db->mutex) );
  if( db && (db->mallocFailed || rc==SQLITE_IOERR_NOMEM) ){
    sqlite3Error(db, SQLITE_NOMEM, 0);
    db->mallocFailed = 0;
    rc = SQLITE_NOMEM;
  }
  return rc & (db ? db->errMask : 0xff);
}