bool FeMedia::openFromFile( const std::string &name, sf::Texture *outt ) { close(); init_av(); if ( avformat_open_input( &(m_imp->m_format_ctx), name.c_str(), NULL, NULL ) < 0 ) { std::cerr << "Error opening input file: " << name << std::endl; return false; } return internal_open( outt ); }
svn_error_t * svn_sqlite__get_schema_version(int *version, const char *path, apr_pool_t *scratch_pool) { svn_sqlite__db_t db; SVN_ERR(svn_atomic__init_once(&sqlite_init_state, init_sqlite, NULL, scratch_pool)); SVN_ERR(internal_open(&db.db3, path, svn_sqlite__mode_readonly, scratch_pool)); SVN_ERR(svn_sqlite__read_schema_version(version, &db, scratch_pool)); SQLITE_ERR(sqlite3_close(db.db3), &db); return SVN_NO_ERROR; }
/** Functions. **/ static void bcm6348_ether_probe( cfe_driver_t * drv, unsigned long probe_a, unsigned long probe_b, void * probe_ptr ) { bcmenet_softc * softc; char descr[100]; softc = (bcmenet_softc *) KMALLOC( sizeof(bcmenet_softc), CACHE_ALIGN ); if( softc == NULL ) { xprintf( "BCM6348 : Failed to allocate softc memory.\n" ); } else { memset( softc, 0, sizeof(bcmenet_softc) ); if (internal_open( softc ) == -1) xprintf("Failed initializing enet hardware\n"); else { cfe_attach( drv, softc, NULL, descr ); } } }
bool FeMedia::openFromArchive( const std::string &archive, const std::string &name, sf::Texture *outt ) { close(); init_av(); FeZipStream *z = new FeZipStream( archive ); if ( !z->open( name ) ) { delete z; return false; } m_imp->m_format_ctx = avformat_alloc_context(); size_t avio_ctx_buffer_size = 4096; uint8_t *avio_ctx_buffer = (uint8_t *)av_malloc( avio_ctx_buffer_size + FF_INPUT_BUFFER_PADDING_SIZE ); memset( avio_ctx_buffer + avio_ctx_buffer_size, 0, FF_INPUT_BUFFER_PADDING_SIZE ); m_imp->m_io_ctx = avio_alloc_context( avio_ctx_buffer, avio_ctx_buffer_size, 0, z, &fe_zip_read, NULL, &fe_zip_seek ); m_imp->m_format_ctx->pb = m_imp->m_io_ctx; if ( avformat_open_input( &(m_imp->m_format_ctx), name.c_str(), NULL, NULL ) < 0 ) { std::cerr << "Error opening input file: " << name << std::endl; return false; } return internal_open( outt ); }
svn_error_t * svn_sqlite__open(svn_sqlite__db_t **db, const char *path, svn_sqlite__mode_t mode, const char * const statements[], int latest_schema, const char * const *upgrade_sql, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { SVN_ERR(svn_atomic__init_once(&sqlite_init_state, init_sqlite, NULL, scratch_pool)); *db = apr_pcalloc(result_pool, sizeof(**db)); SVN_ERR(internal_open(&(*db)->db3, path, mode, scratch_pool)); #ifdef SQLITE3_DEBUG sqlite3_trace((*db)->db3, sqlite_tracer, (*db)->db3); #endif #ifdef SQLITE3_PROFILE sqlite3_profile((*db)->db3, sqlite_profiler, (*db)->db3); #endif /* Work around a bug in SQLite 3.7.7. The bug was fixed in SQLite 3.7.7.1. See: Date: Sun, 26 Jun 2011 18:52:14 -0400 From: Richard Hipp <*****@*****.**> To: General Discussion of SQLite Database <*****@*****.**> Cc: [email protected] Subject: Re: [sqlite] PRAGMA bug in 3.7.7 (but fine in 3.7.6.3) Message-ID: <*****@*****.**> */ { int ignored_err = SQLITE_OK; #if !SQLITE_VERSION_AT_LEAST(3,7,8) && defined(SQLITE_SCHEMA) if (!strcmp(sqlite3_libversion(), "3.7.7")) ignored_err = SQLITE_SCHEMA; #endif SVN_ERR(exec_sql2(*db, "PRAGMA case_sensitive_like=1;", ignored_err)); } SVN_ERR(exec_sql(*db, /* Disable synchronization to disable the explicit disk flushes that make Sqlite up to 50 times slower; especially on small transactions. This removes some stability guarantees on specific hardware and power failures, but still guarantees atomic commits on application crashes. With our dependency on external data like pristine files (Wc) and revision files (repository), we can't keep up these additional guarantees anyway. ### Maybe switch to NORMAL(1) when we use larger transaction scopes */ "PRAGMA synchronous=OFF;" /* Enable recursive triggers so that a user trigger will fire in the deletion phase of an INSERT OR REPLACE statement. Requires SQLite >= 3.6.18 */ "PRAGMA recursive_triggers=ON;")); #if SQLITE_VERSION_AT_LEAST(3,6,19) && defined(SVN_DEBUG) /* When running in debug mode, enable the checking of foreign key constraints. This has possible performance implications, so we don't bother to do it for production...for now. */ SVN_ERR(exec_sql(*db, "PRAGMA foreign_keys=ON;")); #endif /* Store temporary tables in RAM instead of in temporary files, but don't fail on this if this option is disabled in the sqlite compilation by setting SQLITE_TEMP_STORE to 0 (always to disk) */ svn_error_clear(exec_sql(*db, "PRAGMA temp_store = MEMORY;")); /* Validate the schema, upgrading if necessary. */ if (upgrade_sql != NULL) SVN_ERR(check_format(*db, latest_schema, upgrade_sql, scratch_pool)); /* Store the provided statements. */ if (statements) { (*db)->statement_strings = statements; (*db)->nbr_statements = 0; while (*statements != NULL) { statements++; (*db)->nbr_statements++; } (*db)->prepared_stmts = apr_pcalloc(result_pool, (*db)->nbr_statements * sizeof(svn_sqlite__stmt_t *)); } else (*db)->nbr_statements = 0; (*db)->state_pool = result_pool; apr_pool_cleanup_register(result_pool, *db, close_apr, apr_pool_cleanup_null); return SVN_NO_ERROR; }
vo_instance_t * vo_nullskip_open (void) { return internal_open (null_setup, NULL); }
vo_instance_t * vo_null_open (void) { return internal_open (null_setup, null_draw_frame); }
svn_error_t * svn_sqlite__open(svn_sqlite__db_t **db, const char *path, svn_sqlite__mode_t mode, const char * const statements[], int unused1, const char * const *unused2, apr_int32_t timeout, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { SVN_ERR(svn_atomic__init_once(&sqlite_init_state, init_sqlite, NULL, scratch_pool)); *db = apr_pcalloc(result_pool, sizeof(**db)); SVN_ERR(internal_open(*db, path, mode, timeout, scratch_pool)); #if SQLITE_VERSION_NUMBER >= 3008000 && SQLITE_VERSION_NUMBER < 3009000 /* disable SQLITE_ENABLE_STAT3/4 from 3.8.1 - 3.8.3 (but not 3.8.3.1+) * to prevent using it when it's buggy. * See: https://www.sqlite.org/src/info/4c86b126f2 */ if (sqlite3_libversion_number() > 3008000 && sqlite3_libversion_number() < 3008004 && strcmp(sqlite3_sourceid(),"2014-02-11")<0) { sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, (*db)->db3, 0x800); } #endif #ifdef SVN_UNICODE_NORMALIZATION_FIXES /* Create extension buffers with space for 200 UCS-4 characters. */ svn_membuf__create(&(*db)->sqlext_buf1, 800, result_pool); svn_membuf__create(&(*db)->sqlext_buf2, 800, result_pool); svn_membuf__create(&(*db)->sqlext_buf3, 800, result_pool); /* Register collation and LIKE and GLOB operator replacements. */ SQLITE_ERR_CLOSE(sqlite3_create_collation((*db)->db3, "svn-ucs-nfd", SQLITE_UTF8, *db, collate_ucs_nfd), db, scratch_pool); /* ### Is it really necessary to override these functions? I would assume the default implementation to be collation agnostic? And otherwise our implementation should be... The default implementation is in some cases index backed, while our implementation can't be. With an index based on the collation it could be. */ SQLITE_ERR_CLOSE(sqlite3_create_function((*db)->db3, "glob", 2, SQLITE_UTF8 | SQLITE_DETERMINISTIC, *db, glob_ucs_nfd, NULL, NULL), db, scratch_pool); SQLITE_ERR_CLOSE(sqlite3_create_function((*db)->db3, "like", 2, SQLITE_UTF8 | SQLITE_DETERMINISTIC, *db, like_ucs_nfd, NULL, NULL), db, scratch_pool); SQLITE_ERR_CLOSE(sqlite3_create_function((*db)->db3, "like", 3, SQLITE_UTF8 | SQLITE_DETERMINISTIC, *db, like_ucs_nfd, NULL, NULL), db, scratch_pool); #endif /* SVN_UNICODE_NORMALIZATION_FIXES */ #ifdef SQLITE3_DEBUG sqlite3_trace((*db)->db3, sqlite_tracer, (*db)->db3); #endif #ifdef SQLITE3_PROFILE sqlite3_profile((*db)->db3, sqlite_profiler, (*db)->db3); #endif SVN_ERR_CLOSE(exec_sql(*db, /* The default behavior of the LIKE operator is to ignore case for ASCII characters. Hence, by default 'a' LIKE 'A' is true. The case_sensitive_like pragma installs a new application- defined LIKE function that is either case sensitive or insensitive depending on the value of the case_sensitive_like pragma. */ "PRAGMA case_sensitive_like=1;" /* Disable synchronization to disable the explicit disk flushes that make Sqlite up to 50 times slower; especially on small transactions. This removes some stability guarantees on specific hardware and power failures, but still guarantees atomic commits on application crashes. With our dependency on external data like pristine files (Wc) and revision files (repository), we can't keep up these additional guarantees anyway. ### Maybe switch to NORMAL(1) when we use larger transaction scopes */ "PRAGMA synchronous=OFF;" /* Enable recursive triggers so that a user trigger will fire in the deletion phase of an INSERT OR REPLACE statement. Requires SQLite >= 3.6.18 */ "PRAGMA recursive_triggers=ON;" /* Enforce current Sqlite default behavior. Some distributions might change the Sqlite defaults without realizing how this affects application(read: Subversion) performance/behavior. */ "PRAGMA foreign_keys=OFF;" /* SQLITE_DEFAULT_FOREIGN_KEYS*/ "PRAGMA locking_mode = NORMAL;" /* SQLITE_DEFAULT_LOCKING_MODE */ /* Testing shows TRUNCATE is faster than DELETE on Windows. */ "PRAGMA journal_mode = TRUNCATE;" ), *db); #if defined(SVN_DEBUG) /* When running in debug mode, enable the checking of foreign key constraints. This has possible performance implications, so we don't bother to do it for production...for now. */ SVN_ERR_CLOSE(exec_sql(*db, "PRAGMA foreign_keys=ON;"), *db); #endif #ifdef SVN_SQLITE_REVERSE_UNORDERED_SELECTS /* When enabled, this PRAGMA causes SELECT statements without an ORDER BY clause to emit their results in the reverse order of what they normally would. This can help detecting invalid assumptions about the result order.*/ SVN_ERR_CLOSE(exec_sql(*db, "PRAGMA reverse_unordered_selects=ON;"), *db); #endif /* Store temporary tables in RAM instead of in temporary files, but don't fail on this if this option is disabled in the sqlite compilation by setting SQLITE_TEMP_STORE to 0 (always to disk) */ svn_error_clear(exec_sql(*db, "PRAGMA temp_store = MEMORY;")); /* Store the provided statements. */ if (statements) { (*db)->statement_strings = statements; (*db)->nbr_statements = 0; while (*statements != NULL) { statements++; (*db)->nbr_statements++; } (*db)->prepared_stmts = apr_pcalloc( result_pool, ((*db)->nbr_statements + STMT_INTERNAL_LAST) * sizeof(svn_sqlite__stmt_t *)); } else { (*db)->nbr_statements = 0; (*db)->prepared_stmts = apr_pcalloc(result_pool, (0 + STMT_INTERNAL_LAST) * sizeof(svn_sqlite__stmt_t *)); } (*db)->state_pool = result_pool; apr_pool_cleanup_register(result_pool, *db, close_apr, apr_pool_cleanup_null); return SVN_NO_ERROR; }