idx
int64
func
string
target
int64
426,878
String_Schema_Obj Parser::parse_css_variable_value() { String_Schema_Obj schema = SASS_MEMORY_NEW(String_Schema, pstate); std::vector<char> brackets; while (true) { if ( (brackets.empty() && lex< css_variable_top_level_value >(false)) || (!brackets.empty() && lex< css_variable_value >(false)) ) { Token str(lexed); schema->append(SASS_MEMORY_NEW(String_Constant, pstate, str)); } else if (Expression_Obj tok = lex_interpolation()) { if (String_Schema* s = Cast<String_Schema>(tok)) { if (s->empty()) break; schema->concat(s); } else { schema->append(tok); } } else if (lex< quoted_string >()) { Expression_Obj tok = parse_string(); if (tok.isNull()) break; if (String_Schema* s = Cast<String_Schema>(tok)) { if (s->empty()) break; schema->concat(s); } else { schema->append(tok); } } else if (lex< alternatives< exactly<'('>, exactly<'['>, exactly<'{'> > >()) { const char opening_bracket = *(position - 1); brackets.push_back(opening_bracket); schema->append(SASS_MEMORY_NEW(String_Constant, pstate, std::string(1, opening_bracket))); } else if (const char *match = peek< alternatives< exactly<')'>, exactly<']'>, exactly<'}'> > >()) { if (brackets.empty()) break; const char closing_bracket = *(match - 1); if (brackets.back() != Util::opening_bracket_for(closing_bracket)) { std::string message = ": expected \""; message += Util::closing_bracket_for(brackets.back()); message += "\", was "; css_error("Invalid CSS", " after ", message); } lex< alternatives< exactly<')'>, exactly<']'>, exactly<'}'> > >(); schema->append(SASS_MEMORY_NEW(String_Constant, pstate, std::string(1, closing_bracket))); brackets.pop_back(); } else { break; } } if (!brackets.empty()) { std::string message = ": expected \""; message += Util::closing_bracket_for(brackets.back()); message += "\", was "; css_error("Invalid CSS", " after ", message); } if (schema->empty()) return {}; return schema.detach(); }
0
200,267
const base::FilePath& DriveFsHost::GetMountPath() const { DCHECK(IsMounted()); return mount_state_->mount_path(); }
0
514,658
int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); CHECK(args[0]->IsObject()); CHECK(args[1]->IsArray()); Local<Object> req_wrap_obj = args[0].As<Object>(); Local<Array> chunks = args[1].As<Array>(); bool all_buffers = args[2]->IsTrue(); size_t count; if (all_buffers) count = chunks->Length(); else count = chunks->Length() >> 1; MaybeStackBuffer<uv_buf_t, 16> bufs(count); size_t storage_size = 0; size_t offset; if (!all_buffers) { // Determine storage size first for (size_t i = 0; i < count; i++) { Local<Value> chunk = chunks->Get(env->context(), i * 2).ToLocalChecked(); if (Buffer::HasInstance(chunk)) continue; // Buffer chunk, no additional storage required // String chunk Local<String> string = chunk->ToString(env->context()).ToLocalChecked(); enum encoding encoding = ParseEncoding(env->isolate(), chunks->Get(env->context(), i * 2 + 1).ToLocalChecked()); size_t chunk_size; if (encoding == UTF8 && string->Length() > 65535 && !StringBytes::Size(env->isolate(), string, encoding).To(&chunk_size)) return 0; else if (!StringBytes::StorageSize(env->isolate(), string, encoding) .To(&chunk_size)) return 0; storage_size += chunk_size; } if (storage_size > INT_MAX) return UV_ENOBUFS; } else { for (size_t i = 0; i < count; i++) { Local<Value> chunk = chunks->Get(env->context(), i).ToLocalChecked(); bufs[i].base = Buffer::Data(chunk); bufs[i].len = Buffer::Length(chunk); } } AllocatedBuffer storage; if (storage_size > 0) storage = AllocatedBuffer::AllocateManaged(env, storage_size); offset = 0; if (!all_buffers) { for (size_t i = 0; i < count; i++) { Local<Value> chunk = chunks->Get(env->context(), i * 2).ToLocalChecked(); // Write buffer if (Buffer::HasInstance(chunk)) { bufs[i].base = Buffer::Data(chunk); bufs[i].len = Buffer::Length(chunk); continue; } // Write string CHECK_LE(offset, storage_size); char* str_storage = storage.data() + offset; size_t str_size = storage.size() - offset; Local<String> string = chunk->ToString(env->context()).ToLocalChecked(); enum encoding encoding = ParseEncoding(env->isolate(), chunks->Get(env->context(), i * 2 + 1).ToLocalChecked()); str_size = StringBytes::Write(env->isolate(), str_storage, str_size, string, encoding); bufs[i].base = str_storage; bufs[i].len = str_size; offset += str_size; } } StreamWriteResult res = Write(*bufs, count, nullptr, req_wrap_obj); SetWriteResult(res); if (res.wrap != nullptr && storage_size > 0) { res.wrap->SetAllocatedStorage(std::move(storage)); } return res.err; }
0
79,436
static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) { struct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(sb); struct hugetlbfs_inode_info *p; if (unlikely(!hugetlbfs_dec_free_inodes(sbinfo))) return NULL; p = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL); if (unlikely(!p)) { hugetlbfs_inc_free_inodes(sbinfo); return NULL; } return &p->vfs_inode; }
0
213,485
void DataReductionProxyConfig::FetchWarmupProbeURL() { DCHECK(thread_checker_.CalledOnValidThread()); if (params::IsIncludedInHoldbackFieldTrial()) return; if (!enabled_by_user_) { RecordWarmupURLFetchAttemptEvent( WarmupURLFetchAttemptEvent::kProxyNotEnabledByUser); return; } if (!params::FetchWarmupProbeURLEnabled()) { RecordWarmupURLFetchAttemptEvent( WarmupURLFetchAttemptEvent::kWarmupURLFetchingDisabled); return; } if (connection_type_ == network::mojom::ConnectionType::CONNECTION_NONE) { RecordWarmupURLFetchAttemptEvent( WarmupURLFetchAttemptEvent::kConnectionTypeNone); return; } base::Optional<DataReductionProxyServer> warmup_proxy = GetProxyConnectionToProbe(); if (!warmup_proxy) return; warmup_url_fetch_in_flight_secure_proxy_ = warmup_proxy->IsSecureProxy(); warmup_url_fetch_in_flight_core_proxy_ = warmup_proxy->IsCoreProxy(); size_t previous_attempt_counts = GetWarmupURLFetchAttemptCounts(); network_properties_manager_->OnWarmupFetchInitiated( warmup_url_fetch_in_flight_secure_proxy_, warmup_url_fetch_in_flight_core_proxy_); RecordWarmupURLFetchAttemptEvent(WarmupURLFetchAttemptEvent::kFetchInitiated); warmup_url_fetcher_->FetchWarmupURL(previous_attempt_counts, warmup_proxy.value()); }
0
520,810
bool save_in_value(THD *thd, struct st_value *value) { return type_handler()->Item_save_in_value(thd, this, value); }
0
42,182
static inline bool cpu_has_vmx_ept(void) { return vmcs_config.cpu_based_2nd_exec_ctrl & SECONDARY_EXEC_ENABLE_EPT; }
0
399,505
SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp, struct timespec __user *, rmtp) { struct timespec tu; if (copy_from_user(&tu, rqtp, sizeof(tu))) return -EFAULT; if (!timespec_valid(&tu)) return -EINVAL; return hrtimer_nanosleep(&tu, rmtp, HRTIMER_MODE_REL, CLOCK_MONOTONIC); }
0
151,452
void MainWindow::dropEvent(QDropEvent *event) { const QMimeData *mimeData = event->mimeData(); if (mimeData->hasFormat("application/x-qabstractitemmodeldatalist")) { QByteArray encoded = mimeData->data("application/x-qabstractitemmodeldatalist"); QDataStream stream(&encoded, QIODevice::ReadOnly); QMap<int, QVariant> roleDataMap; while (!stream.atEnd()) { int row, col; stream >> row >> col >> roleDataMap; } if (roleDataMap.contains(Qt::ToolTipRole)) { // DisplayRole is just basename, ToolTipRole contains full path open(roleDataMap[Qt::ToolTipRole].toString()); event->acceptProposedAction(); } } else if (mimeData->hasUrls()) { openMultiple(mimeData->urls()); event->acceptProposedAction(); } else if (mimeData->hasFormat(Mlt::XmlMimeType )) { m_playlistDock->on_actionOpen_triggered(); event->acceptProposedAction(); } }
0
478,753
const CImg<T>& _save_inr(std::FILE *const file, const char *const filename, const float *const voxel_size) const { if (!file && !filename) throw CImgArgumentException(_cimg_instance "save_inr(): Specified filename is (null).", cimg_instance); if (is_empty()) { cimg::fempty(file,filename); return *this; } int inrpixsize = -1; const char *inrtype = "unsigned fixed\nPIXSIZE=8 bits\nSCALE=2**0"; if (!cimg::strcasecmp(pixel_type(),"unsigned char")) { inrtype = "unsigned fixed\nPIXSIZE=8 bits\nSCALE=2**0"; inrpixsize = 1; } if (!cimg::strcasecmp(pixel_type(),"char")) { inrtype = "fixed\nPIXSIZE=8 bits\nSCALE=2**0"; inrpixsize = 1; } if (!cimg::strcasecmp(pixel_type(),"unsigned short")) { inrtype = "unsigned fixed\nPIXSIZE=16 bits\nSCALE=2**0";inrpixsize = 2; } if (!cimg::strcasecmp(pixel_type(),"short")) { inrtype = "fixed\nPIXSIZE=16 bits\nSCALE=2**0"; inrpixsize = 2; } if (!cimg::strcasecmp(pixel_type(),"unsigned int")) { inrtype = "unsigned fixed\nPIXSIZE=32 bits\nSCALE=2**0";inrpixsize = 4; } if (!cimg::strcasecmp(pixel_type(),"int")) { inrtype = "fixed\nPIXSIZE=32 bits\nSCALE=2**0"; inrpixsize = 4; } if (!cimg::strcasecmp(pixel_type(),"float")) { inrtype = "float\nPIXSIZE=32 bits"; inrpixsize = 4; } if (!cimg::strcasecmp(pixel_type(),"double")) { inrtype = "float\nPIXSIZE=64 bits"; inrpixsize = 8; } if (inrpixsize<=0) throw CImgIOException(_cimg_instance "save_inr(): Unsupported pixel type '%s' for file '%s'", cimg_instance, pixel_type(),filename?filename:"(FILE*)"); std::FILE *const nfile = file?file:cimg::fopen(filename,"wb"); CImg<charT> header(257); int err = cimg_snprintf(header,header._width,"#INRIMAGE-4#{\nXDIM=%u\nYDIM=%u\nZDIM=%u\nVDIM=%u\n", _width,_height,_depth,_spectrum); if (voxel_size) err+=cimg_sprintf(header._data + err,"VX=%g\nVY=%g\nVZ=%g\n", voxel_size[0],voxel_size[1],voxel_size[2]); err+=cimg_sprintf(header._data + err,"TYPE=%s\nCPU=%s\n",inrtype,cimg::endianness()?"sun":"decm"); std::memset(header._data + err,'\n',252 - err); std::memcpy(header._data + 252,"##}\n",4); cimg::fwrite(header._data,256,nfile); cimg_forXYZ(*this,x,y,z) cimg_forC(*this,c) cimg::fwrite(&((*this)(x,y,z,c)),1,nfile); if (!file) cimg::fclose(nfile); return *this; }
0
360,332
show_thumbnails_changed_callback (gpointer user_data) { show_image_thumbs = eel_preferences_get_enum (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS); /* Tell the world that icons might have changed. We could invent a narrower-scope * signal to mean only "thumbnails might have changed" if this ends up being slow * for some reason. */ emit_change_signals_for_all_files_in_all_directories (); }
0
470,610
void usbredirparser_send_alloc_bulk_streams(struct usbredirparser *parser, uint64_t id, struct usb_redir_alloc_bulk_streams_header *alloc_bulk_streams) { usbredirparser_queue(parser, usb_redir_alloc_bulk_streams, id, alloc_bulk_streams, NULL, 0); }
0
98,769
int imap_get_literal_count(const char *buf, unsigned int *bytes) { char *pc; char *pn; if (!buf || !(pc = strchr (buf, '{'))) return -1; pc++; pn = pc; while (isdigit ((unsigned char) *pc)) pc++; *pc = 0; if (mutt_atoui (pn, bytes) < 0) return -1; return 0; }
0
159,375
static void add_mm_counter_fast(struct mm_struct *mm, int member, int val) { struct task_struct *task = current; if (likely(task->mm == mm)) task->rss_stat.count[member] += val; else add_mm_counter(mm, member, val); }
0
59,954
int _yr_re_fiber_exists( RE_FIBER_LIST* fiber_list, RE_FIBER* target_fiber, RE_FIBER* last_fiber) { RE_FIBER* fiber = fiber_list->head; int equal_stacks; int i; if (last_fiber == NULL) return FALSE; while (fiber != last_fiber->next) { if (fiber->ip == target_fiber->ip && fiber->sp == target_fiber->sp && fiber->rc == target_fiber->rc) { equal_stacks = TRUE; for (i = 0; i <= fiber->sp; i++) { if (fiber->stack[i] != target_fiber->stack[i]) { equal_stacks = FALSE; break; } } if (equal_stacks) return TRUE; } fiber = fiber->next; } return FALSE; }
0
126,572
static void ResetCaption() { GF_Event event; if (display_rti) return; event.type = GF_EVENT_SET_CAPTION; if (is_connected) { char szName[1024]; NetInfoCommand com; event.caption.caption = NULL; /*get any service info*/ if (!startup_file && gf_term_get_service_info(term, gf_term_get_root_object(term), &com) == GF_OK) { strcpy(szName, ""); if (com.track_info) { char szBuf[10]; sprintf(szBuf, "%02d ", (u32) (com.track_info>>16) ); strcat(szName, szBuf); } if (com.artist) { strcat(szName, com.artist); strcat(szName, " "); } if (com.name) { strcat(szName, com.name); strcat(szName, " "); } if (com.album) { strcat(szName, "("); strcat(szName, com.album); strcat(szName, ")"); } if (com.provider) { strcat(szName, "("); strcat(szName, com.provider); strcat(szName, ")"); } if (strlen(szName)) event.caption.caption = szName; } if (!event.caption.caption) { char *str = strrchr(the_url, '\\'); if (!str) str = strrchr(the_url, '/'); event.caption.caption = str ? str+1 : the_url; } } else { event.caption.caption = "GPAC MP4Client " GPAC_FULL_VERSION; } gf_term_user_event(term, &event); }
0
155,537
static int ssl_parse_hello_verify_request( mbedtls_ssl_context *ssl ) { const unsigned char *p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); int major_ver, minor_ver; unsigned char cookie_len; MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse hello verify request" ) ); /* * struct { * ProtocolVersion server_version; * opaque cookie<0..2^8-1>; * } HelloVerifyRequest; */ MBEDTLS_SSL_DEBUG_BUF( 3, "server version", p, 2 ); mbedtls_ssl_read_version( &major_ver, &minor_ver, ssl->conf->transport, p ); p += 2; /* * Since the RFC is not clear on this point, accept DTLS 1.0 (TLS 1.1) * even is lower than our min version. */ if( major_ver < MBEDTLS_SSL_MAJOR_VERSION_3 || minor_ver < MBEDTLS_SSL_MINOR_VERSION_2 || major_ver > ssl->conf->max_major_ver || minor_ver > ssl->conf->max_minor_ver ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server version" ) ); mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION ); return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION ); } cookie_len = *p++; MBEDTLS_SSL_DEBUG_BUF( 3, "cookie", p, cookie_len ); if( ( ssl->in_msg + ssl->in_msglen ) - p < cookie_len ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "cookie length does not match incoming message size" ) ); mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); } mbedtls_free( ssl->handshake->verify_cookie ); ssl->handshake->verify_cookie = mbedtls_calloc( 1, cookie_len ); if( ssl->handshake->verify_cookie == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc failed (%d bytes)", cookie_len ) ); return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); } memcpy( ssl->handshake->verify_cookie, p, cookie_len ); ssl->handshake->verify_cookie_len = cookie_len; /* Start over at ClientHello */ ssl->state = MBEDTLS_SSL_CLIENT_HELLO; mbedtls_ssl_reset_checksum( ssl ); mbedtls_ssl_recv_flight_completed( ssl ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse hello verify request" ) ); return( 0 ); }
0
503,028
static void hdb_samba4_free_entry_context(krb5_context context, struct HDB *db, hdb_entry *entry) { /* * This function is now called for every HDB entry, not just those with * 'context' set, so we have to check that the context is not NULL. */ if (entry->context != NULL) { struct samba_kdc_entry *skdc_entry = talloc_get_type_abort(entry->context, struct samba_kdc_entry); /* this function is called only from hdb_free_entry(). * Make sure we neutralize the destructor or we will * get a double free later when hdb_free_entry() will * try to call free_hdb_entry() */ entry->context = NULL; skdc_entry->kdc_entry = NULL; TALLOC_FREE(skdc_entry); } }
0
40,185
int puma_parser_is_finished(puma_parser *parser) { return parser->cs >= puma_parser_first_final; }
0
36,108
find_next_completion_match( int allow_get_expansion, int todo, // repeat completion this many times int advance, int *num_matches) { int found_end = FALSE; compl_T *found_compl = NULL; while (--todo >= 0) { if (compl_shows_dir_forward() && compl_shown_match->cp_next != NULL) { compl_shown_match = compl_shown_match->cp_next; found_end = (compl_first_match != NULL && (is_first_match(compl_shown_match->cp_next) || is_first_match(compl_shown_match))); } else if (compl_shows_dir_backward() && compl_shown_match->cp_prev != NULL) { found_end = is_first_match(compl_shown_match); compl_shown_match = compl_shown_match->cp_prev; found_end |= is_first_match(compl_shown_match); } else { if (!allow_get_expansion) { if (advance) { if (compl_shows_dir_backward()) compl_pending -= todo + 1; else compl_pending += todo + 1; } return -1; } if (!compl_no_select && advance) { if (compl_shows_dir_backward()) --compl_pending; else ++compl_pending; } // Find matches. *num_matches = ins_compl_get_exp(&compl_startpos); // handle any pending completions while (compl_pending != 0 && compl_direction == compl_shows_dir && advance) { if (compl_pending > 0 && compl_shown_match->cp_next != NULL) { compl_shown_match = compl_shown_match->cp_next; --compl_pending; } if (compl_pending < 0 && compl_shown_match->cp_prev != NULL) { compl_shown_match = compl_shown_match->cp_prev; ++compl_pending; } else break; } found_end = FALSE; } if (!match_at_original_text(compl_shown_match) && compl_leader != NULL && !ins_compl_equal(compl_shown_match, compl_leader, (int)STRLEN(compl_leader))) ++todo; else // Remember a matching item. found_compl = compl_shown_match; // Stop at the end of the list when we found a usable match. if (found_end) { if (found_compl != NULL) { compl_shown_match = found_compl; break; } todo = 1; // use first usable match after wrapping around } } return OK; }
0
103,898
static int GetCertHeader(DecodedCert* cert) { int ret = 0, len; if (GetSequence(cert->source, &cert->srcIdx, &len, cert->maxIdx) < 0) return ASN_PARSE_E; /* Reset the max index for the size indicated in the outer wrapper. */ cert->maxIdx = len + cert->srcIdx; cert->certBegin = cert->srcIdx; if (GetSequence(cert->source, &cert->srcIdx, &len, cert->maxIdx) < 0) return ASN_PARSE_E; cert->sigIndex = len + cert->srcIdx; if (cert->sigIndex > cert->maxIdx) return ASN_PARSE_E; if (GetExplicitVersion(cert->source, &cert->srcIdx, &cert->version, cert->sigIndex) < 0) return ASN_PARSE_E; if (GetSerialNumber(cert->source, &cert->srcIdx, cert->serial, &cert->serialSz, cert->sigIndex) < 0) return ASN_PARSE_E; return ret; }
0
175,876
void CL_InitRef( void ) { refimport_t ri; refexport_t *ret; #ifdef USE_RENDERER_DLOPEN GetRefAPI_t GetRefAPI; char dllName[MAX_OSPATH]; #endif Com_Printf( "----- Initializing Renderer ----\n" ); #ifdef USE_RENDERER_DLOPEN cl_renderer = Cvar_Get("cl_renderer", "opengl1", CVAR_ARCHIVE | CVAR_LATCH | CVAR_PROTECTED); Com_sprintf(dllName, sizeof(dllName), "renderer_sp_%s_" ARCH_STRING DLL_EXT, cl_renderer->string); if(!(rendererLib = Sys_LoadDll(dllName, qfalse)) && strcmp(cl_renderer->string, cl_renderer->resetString)) { Com_Printf("failed:\n\"%s\"\n", Sys_LibraryError()); Cvar_ForceReset("cl_renderer"); Com_sprintf(dllName, sizeof(dllName), "renderer_sp_opengl1_" ARCH_STRING DLL_EXT); rendererLib = Sys_LoadDll(dllName, qfalse); } if(!rendererLib) { Com_Printf("failed:\n\"%s\"\n", Sys_LibraryError()); Com_Error(ERR_FATAL, "Failed to load renderer"); } GetRefAPI = Sys_LoadFunction(rendererLib, "GetRefAPI"); if(!GetRefAPI) { Com_Error(ERR_FATAL, "Can't load symbol GetRefAPI: '%s'", Sys_LibraryError()); } #endif ri.Cmd_AddCommand = Cmd_AddCommand; ri.Cmd_RemoveCommand = Cmd_RemoveCommand; ri.Cmd_Argc = Cmd_Argc; ri.Cmd_Argv = Cmd_Argv; ri.Cmd_ExecuteText = Cbuf_ExecuteText; ri.Printf = CL_RefPrintf; ri.Error = Com_Error; ri.Milliseconds = CL_ScaledMilliseconds; ri.Z_Malloc = Z_Malloc; ri.Free = Z_Free; ri.Hunk_Clear = Hunk_ClearToMark; #ifdef HUNK_DEBUG ri.Hunk_AllocDebug = Hunk_AllocDebug; #else ri.Hunk_Alloc = Hunk_Alloc; #endif ri.Hunk_AllocateTempMemory = Hunk_AllocateTempMemory; ri.Hunk_FreeTempMemory = Hunk_FreeTempMemory; ri.CM_ClusterPVS = CM_ClusterPVS; ri.CM_DrawDebugSurface = CM_DrawDebugSurface; ri.FS_ReadFile = FS_ReadFile; ri.FS_FreeFile = FS_FreeFile; ri.FS_WriteFile = FS_WriteFile; ri.FS_FreeFileList = FS_FreeFileList; ri.FS_ListFiles = FS_ListFiles; ri.FS_FileIsInPAK = FS_FileIsInPAK; ri.FS_FileExists = FS_FileExists; ri.Cvar_Get = Cvar_Get; ri.Cvar_Set = Cvar_Set; ri.Cvar_SetValue = Cvar_SetValue; ri.Cvar_CheckRange = Cvar_CheckRange; ri.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue; ri.CIN_UploadCinematic = CIN_UploadCinematic; ri.CIN_PlayCinematic = CIN_PlayCinematic; ri.CIN_RunCinematic = CIN_RunCinematic; ri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame; ri.IN_Init = IN_Init; ri.IN_Shutdown = IN_Shutdown; ri.IN_Restart = IN_Restart; ri.ftol = Q_ftol; ri.Sys_SetEnv = Sys_SetEnv; ri.Sys_GLimpSafeInit = Sys_GLimpSafeInit; ri.Sys_GLimpInit = Sys_GLimpInit; ri.Sys_LowPhysicalMemory = Sys_LowPhysicalMemory; ret = GetRefAPI( REF_API_VERSION, &ri ); if ( !ret ) { Com_Error( ERR_FATAL, "Couldn't initialize refresh" ); } re = *ret; Com_Printf( "---- Renderer Initialization Complete ----\n" ); Cvar_Set( "cl_paused", "0" ); }
0
446,635
virDomainStorageSourceParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virStorageSourcePtr src, unsigned int flags, virDomainXMLOptionPtr xmlopt) { VIR_XPATH_NODE_AUTORESTORE(ctxt); xmlNodePtr tmp; ctxt->node = node; switch ((virStorageType)src->type) { case VIR_STORAGE_TYPE_FILE: src->path = virXMLPropString(node, "file"); break; case VIR_STORAGE_TYPE_BLOCK: src->path = virXMLPropString(node, "dev"); break; case VIR_STORAGE_TYPE_DIR: src->path = virXMLPropString(node, "dir"); break; case VIR_STORAGE_TYPE_NETWORK: if (virDomainDiskSourceNetworkParse(node, ctxt, src, flags) < 0) return -1; break; case VIR_STORAGE_TYPE_VOLUME: if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0) return -1; break; case VIR_STORAGE_TYPE_NVME: if (virDomainDiskSourceNVMeParse(node, ctxt, src) < 0) return -1; break; case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk type %s"), virStorageTypeToString(src->type)); return -1; } if ((tmp = virXPathNode("./auth", ctxt)) && !(src->auth = virStorageAuthDefParse(tmp, ctxt))) return -1; if ((tmp = virXPathNode("./encryption", ctxt)) && !(src->encryption = virStorageEncryptionParseNode(tmp, ctxt))) return -1; if (virDomainDiskSourcePRParse(node, ctxt, &src->pr) < 0) return -1; if (virDomainStorageSourceParseSlices(src, ctxt) < 0) return -1; if (virSecurityDeviceLabelDefParseXML(&src->seclabels, &src->nseclabels, ctxt, flags) < 0) return -1; /* People sometimes pass a bogus '' source path when they mean to omit the * source element completely (e.g. CDROM without media). This is just a * little compatibility check to help those broken apps */ if (src->path && !*src->path) VIR_FREE(src->path); if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && xmlopt && xmlopt->privateData.storageParse && (tmp = virXPathNode("./privateData", ctxt))) { ctxt->node = tmp; if (xmlopt->privateData.storageParse(ctxt, src) < 0) return -1; } return 0; }
0
129,539
static MagickBooleanType WriteMNGImage(const ImageInfo *image_info,Image *image) { const char *option; Image *next_image; MagickBooleanType status; volatile MagickBooleanType logging; MngInfo *mng_info; int image_count, need_iterations, need_matte; volatile int #if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_MNG_FEATURES_SUPPORTED) need_local_plte, #endif all_images_are_gray, need_defi, use_global_plte; register ssize_t i; unsigned char chunk[800]; volatile unsigned int write_jng, write_mng; volatile size_t scene; size_t final_delay=0, initial_delay, imageListLength; #if (PNG_LIBPNG_VER < 10200) if (image_info->verbose) printf("Your PNG library (libpng-%s) is rather old.\n", PNG_LIBPNG_VER_STRING); #endif /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); logging=LogMagickEvent(CoderEvent,GetMagickModule(),"Enter WriteMNGImage()"); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); /* Allocate a MngInfo structure. */ mng_info=(MngInfo *) AcquireMagickMemory(sizeof(MngInfo)); if (mng_info == (MngInfo *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); /* Initialize members of the MngInfo structure. */ (void) memset(mng_info,0,sizeof(MngInfo)); mng_info->image=image; write_mng=LocaleCompare(image_info->magick,"MNG") == 0; /* * See if user has requested a specific PNG subformat to be used * for all of the PNGs in the MNG being written, e.g., * * convert *.png png8:animation.mng * * To do: check -define png:bit_depth and png:color_type as well, * or perhaps use mng:bit_depth and mng:color_type instead for * global settings. */ mng_info->write_png8=LocaleCompare(image_info->magick,"PNG8") == 0; mng_info->write_png24=LocaleCompare(image_info->magick,"PNG24") == 0; mng_info->write_png32=LocaleCompare(image_info->magick,"PNG32") == 0; write_jng=MagickFalse; if (image_info->compression == JPEGCompression) write_jng=MagickTrue; mng_info->adjoin=image_info->adjoin && (GetNextImageInList(image) != (Image *) NULL) && write_mng; if (logging != MagickFalse) { /* Log some info about the input */ Image *p; (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Checking input image(s)\n" " Image_info depth: %.20g, Type: %d", (double) image_info->depth, image_info->type); scene=0; for (p=image; p != (Image *) NULL; p=GetNextImageInList(p)) { (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Scene: %.20g\n, Image depth: %.20g", (double) scene++, (double) p->depth); if (p->matte) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Matte: True"); else (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Matte: False"); if (p->storage_class == PseudoClass) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Storage class: PseudoClass"); else (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Storage class: DirectClass"); if (p->colors) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Number of colors: %.20g",(double) p->colors); else (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Number of colors: unspecified"); if (mng_info->adjoin == MagickFalse) break; } } use_global_plte=MagickFalse; all_images_are_gray=MagickFalse; #ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED need_local_plte=MagickTrue; #endif need_defi=MagickFalse; need_matte=MagickFalse; mng_info->framing_mode=1; mng_info->old_framing_mode=1; if (write_mng) if (image_info->page != (char *) NULL) { /* Determine image bounding box. */ SetGeometry(image,&mng_info->page); (void) ParseMetaGeometry(image_info->page,&mng_info->page.x, &mng_info->page.y,&mng_info->page.width,&mng_info->page.height); } if (write_mng) { unsigned int need_geom; unsigned short red, green, blue; mng_info->page=image->page; need_geom=MagickTrue; if (mng_info->page.width || mng_info->page.height) need_geom=MagickFalse; /* Check all the scenes. */ initial_delay=image->delay; need_iterations=MagickFalse; mng_info->equal_chrms=image->chromaticity.red_primary.x != 0.0; mng_info->equal_physs=MagickTrue, mng_info->equal_gammas=MagickTrue; mng_info->equal_srgbs=MagickTrue; mng_info->equal_backgrounds=MagickTrue; image_count=0; #if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_MNG_FEATURES_SUPPORTED) all_images_are_gray=MagickTrue; mng_info->equal_palettes=MagickFalse; need_local_plte=MagickFalse; #endif for (next_image=image; next_image != (Image *) NULL; ) { if (need_geom) { if ((next_image->columns+next_image->page.x) > mng_info->page.width) mng_info->page.width=next_image->columns+next_image->page.x; if ((next_image->rows+next_image->page.y) > mng_info->page.height) mng_info->page.height=next_image->rows+next_image->page.y; } if (next_image->page.x || next_image->page.y) need_defi=MagickTrue; if (next_image->matte) need_matte=MagickTrue; if ((int) next_image->dispose >= BackgroundDispose) if (next_image->matte || next_image->page.x || next_image->page.y || ((next_image->columns < mng_info->page.width) && (next_image->rows < mng_info->page.height))) mng_info->need_fram=MagickTrue; if (next_image->iterations) need_iterations=MagickTrue; final_delay=next_image->delay; if (final_delay != initial_delay || final_delay > 1UL* next_image->ticks_per_second) mng_info->need_fram=1; #if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_MNG_FEATURES_SUPPORTED) /* check for global palette possibility. */ if (image->matte != MagickFalse) need_local_plte=MagickTrue; if (need_local_plte == 0) { if (SetImageGray(image,&image->exception) == MagickFalse) all_images_are_gray=MagickFalse; mng_info->equal_palettes=PalettesAreEqual(image,next_image); if (use_global_plte == 0) use_global_plte=mng_info->equal_palettes; need_local_plte=!mng_info->equal_palettes; } #endif if (GetNextImageInList(next_image) != (Image *) NULL) { if (next_image->background_color.red != next_image->next->background_color.red || next_image->background_color.green != next_image->next->background_color.green || next_image->background_color.blue != next_image->next->background_color.blue) mng_info->equal_backgrounds=MagickFalse; if (next_image->gamma != next_image->next->gamma) mng_info->equal_gammas=MagickFalse; if (next_image->rendering_intent != next_image->next->rendering_intent) mng_info->equal_srgbs=MagickFalse; if ((next_image->units != next_image->next->units) || (next_image->x_resolution != next_image->next->x_resolution) || (next_image->y_resolution != next_image->next->y_resolution)) mng_info->equal_physs=MagickFalse; if (mng_info->equal_chrms) { if (next_image->chromaticity.red_primary.x != next_image->next->chromaticity.red_primary.x || next_image->chromaticity.red_primary.y != next_image->next->chromaticity.red_primary.y || next_image->chromaticity.green_primary.x != next_image->next->chromaticity.green_primary.x || next_image->chromaticity.green_primary.y != next_image->next->chromaticity.green_primary.y || next_image->chromaticity.blue_primary.x != next_image->next->chromaticity.blue_primary.x || next_image->chromaticity.blue_primary.y != next_image->next->chromaticity.blue_primary.y || next_image->chromaticity.white_point.x != next_image->next->chromaticity.white_point.x || next_image->chromaticity.white_point.y != next_image->next->chromaticity.white_point.y) mng_info->equal_chrms=MagickFalse; } } image_count++; next_image=GetNextImageInList(next_image); } if (image_count < 2) { mng_info->equal_backgrounds=MagickFalse; mng_info->equal_chrms=MagickFalse; mng_info->equal_gammas=MagickFalse; mng_info->equal_srgbs=MagickFalse; mng_info->equal_physs=MagickFalse; use_global_plte=MagickFalse; #ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED need_local_plte=MagickTrue; #endif need_iterations=MagickFalse; } if (mng_info->need_fram == MagickFalse) { /* Only certain framing rates 100/n are exactly representable without the FRAM chunk but we'll allow some slop in VLC files */ if (final_delay == 0) { if (need_iterations != MagickFalse) { /* It's probably a GIF with loop; don't run it *too* fast. */ if (mng_info->adjoin) { final_delay=10; (void) ThrowMagickException(&image->exception, GetMagickModule(),CoderWarning, "input has zero delay between all frames; assuming", " 10 cs `%s'",""); } } else mng_info->ticks_per_second=0; } if (final_delay != 0) mng_info->ticks_per_second=(png_uint_32) (image->ticks_per_second/final_delay); if (final_delay > 50) mng_info->ticks_per_second=2; if (final_delay > 75) mng_info->ticks_per_second=1; if (final_delay > 125) mng_info->need_fram=MagickTrue; if (need_defi && final_delay > 2 && (final_delay != 4) && (final_delay != 5) && (final_delay != 10) && (final_delay != 20) && (final_delay != 25) && (final_delay != 50) && (final_delay != (size_t) image->ticks_per_second)) mng_info->need_fram=MagickTrue; /* make it exact; cannot be VLC */ } if (mng_info->need_fram != MagickFalse) mng_info->ticks_per_second=1UL*image->ticks_per_second; /* If pseudocolor, we should also check to see if all the palettes are identical and write a global PLTE if they are. ../glennrp Feb 99. */ /* Write the MNG version 1.0 signature and MHDR chunk. */ (void) WriteBlob(image,8,(const unsigned char *) "\212MNG\r\n\032\n"); (void) WriteBlobMSBULong(image,28L); /* chunk data length=28 */ PNGType(chunk,mng_MHDR); LogPNGChunk(logging,mng_MHDR,28L); PNGLong(chunk+4,(png_uint_32) mng_info->page.width); PNGLong(chunk+8,(png_uint_32) mng_info->page.height); PNGLong(chunk+12,mng_info->ticks_per_second); PNGLong(chunk+16,0L); /* layer count=unknown */ PNGLong(chunk+20,0L); /* frame count=unknown */ PNGLong(chunk+24,0L); /* play time=unknown */ if (write_jng) { if (need_matte) { if (need_defi || mng_info->need_fram || use_global_plte) PNGLong(chunk+28,27L); /* simplicity=LC+JNG */ else PNGLong(chunk+28,25L); /* simplicity=VLC+JNG */ } else { if (need_defi || mng_info->need_fram || use_global_plte) PNGLong(chunk+28,19L); /* simplicity=LC+JNG, no transparency */ else PNGLong(chunk+28,17L); /* simplicity=VLC+JNG, no transparency */ } } else { if (need_matte) { if (need_defi || mng_info->need_fram || use_global_plte) PNGLong(chunk+28,11L); /* simplicity=LC */ else PNGLong(chunk+28,9L); /* simplicity=VLC */ } else { if (need_defi || mng_info->need_fram || use_global_plte) PNGLong(chunk+28,3L); /* simplicity=LC, no transparency */ else PNGLong(chunk+28,1L); /* simplicity=VLC, no transparency */ } } (void) WriteBlob(image,32,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,32)); option=GetImageOption(image_info,"mng:need-cacheoff"); if (option != (const char *) NULL) { size_t length; /* Write "nEED CACHEOFF" to turn playback caching off for streaming MNG. */ PNGType(chunk,mng_nEED); length=CopyMagickString((char *) chunk+4,"CACHEOFF",20); (void) WriteBlobMSBULong(image,(size_t) length); LogPNGChunk(logging,mng_nEED,(size_t) length); length+=4; (void) WriteBlob(image,length,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) length)); } if ((GetPreviousImageInList(image) == (Image *) NULL) && (GetNextImageInList(image) != (Image *) NULL) && (image->iterations != 1)) { /* Write MNG TERM chunk */ (void) WriteBlobMSBULong(image,10L); /* data length=10 */ PNGType(chunk,mng_TERM); LogPNGChunk(logging,mng_TERM,10L); chunk[4]=3; /* repeat animation */ chunk[5]=0; /* show last frame when done */ PNGLong(chunk+6,(png_uint_32) (mng_info->ticks_per_second* final_delay/MagickMax(image->ticks_per_second,1))); if (image->iterations == 0) PNGLong(chunk+10,PNG_UINT_31_MAX); else PNGLong(chunk+10,(png_uint_32) image->iterations); if (logging != MagickFalse) { (void) LogMagickEvent(CoderEvent,GetMagickModule(), " TERM delay: %.20g",(double) (mng_info->ticks_per_second* final_delay/MagickMax(image->ticks_per_second,1))); if (image->iterations == 0) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " TERM iterations: %.20g",(double) PNG_UINT_31_MAX); else (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Image iterations: %.20g",(double) image->iterations); } (void) WriteBlob(image,14,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,14)); } /* To do: check for cHRM+gAMA == sRGB, and write sRGB instead. */ if ((image->colorspace == sRGBColorspace || image->rendering_intent) && mng_info->equal_srgbs) { /* Write MNG sRGB chunk */ (void) WriteBlobMSBULong(image,1L); PNGType(chunk,mng_sRGB); LogPNGChunk(logging,mng_sRGB,1L); if (image->rendering_intent != UndefinedIntent) chunk[4]=(unsigned char) Magick_RenderingIntent_to_PNG_RenderingIntent( (image->rendering_intent)); else chunk[4]=(unsigned char) Magick_RenderingIntent_to_PNG_RenderingIntent( (PerceptualIntent)); (void) WriteBlob(image,5,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,5)); mng_info->have_write_global_srgb=MagickTrue; } else { if (image->gamma && mng_info->equal_gammas) { /* Write MNG gAMA chunk */ (void) WriteBlobMSBULong(image,4L); PNGType(chunk,mng_gAMA); LogPNGChunk(logging,mng_gAMA,4L); PNGLong(chunk+4,(png_uint_32) (100000*image->gamma+0.5)); (void) WriteBlob(image,8,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,8)); mng_info->have_write_global_gama=MagickTrue; } if (mng_info->equal_chrms) { PrimaryInfo primary; /* Write MNG cHRM chunk */ (void) WriteBlobMSBULong(image,32L); PNGType(chunk,mng_cHRM); LogPNGChunk(logging,mng_cHRM,32L); primary=image->chromaticity.white_point; PNGLong(chunk+4,(png_uint_32) (100000*primary.x+0.5)); PNGLong(chunk+8,(png_uint_32) (100000*primary.y+0.5)); primary=image->chromaticity.red_primary; PNGLong(chunk+12,(png_uint_32) (100000*primary.x+0.5)); PNGLong(chunk+16,(png_uint_32) (100000*primary.y+0.5)); primary=image->chromaticity.green_primary; PNGLong(chunk+20,(png_uint_32) (100000*primary.x+0.5)); PNGLong(chunk+24,(png_uint_32) (100000*primary.y+0.5)); primary=image->chromaticity.blue_primary; PNGLong(chunk+28,(png_uint_32) (100000*primary.x+0.5)); PNGLong(chunk+32,(png_uint_32) (100000*primary.y+0.5)); (void) WriteBlob(image,36,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,36)); mng_info->have_write_global_chrm=MagickTrue; } } if (image->x_resolution && image->y_resolution && mng_info->equal_physs) { /* Write MNG pHYs chunk */ (void) WriteBlobMSBULong(image,9L); PNGType(chunk,mng_pHYs); LogPNGChunk(logging,mng_pHYs,9L); if (image->units == PixelsPerInchResolution) { PNGLong(chunk+4,(png_uint_32) (image->x_resolution*100.0/2.54+0.5)); PNGLong(chunk+8,(png_uint_32) (image->y_resolution*100.0/2.54+0.5)); chunk[12]=1; } else { if (image->units == PixelsPerCentimeterResolution) { PNGLong(chunk+4,(png_uint_32) (image->x_resolution*100.0+0.5)); PNGLong(chunk+8,(png_uint_32) (image->y_resolution*100.0+0.5)); chunk[12]=1; } else { PNGLong(chunk+4,(png_uint_32) (image->x_resolution+0.5)); PNGLong(chunk+8,(png_uint_32) (image->y_resolution+0.5)); chunk[12]=0; } } (void) WriteBlob(image,13,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,13)); } /* Write MNG BACK chunk and global bKGD chunk, if the image is transparent or does not cover the entire frame. */ if (write_mng && (image->matte || image->page.x > 0 || image->page.y > 0 || (image->page.width && (image->page.width+image->page.x < mng_info->page.width)) || (image->page.height && (image->page.height+image->page.y < mng_info->page.height)))) { (void) WriteBlobMSBULong(image,6L); PNGType(chunk,mng_BACK); LogPNGChunk(logging,mng_BACK,6L); red=ScaleQuantumToShort(image->background_color.red); green=ScaleQuantumToShort(image->background_color.green); blue=ScaleQuantumToShort(image->background_color.blue); PNGShort(chunk+4,red); PNGShort(chunk+6,green); PNGShort(chunk+8,blue); (void) WriteBlob(image,10,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,10)); if (mng_info->equal_backgrounds) { (void) WriteBlobMSBULong(image,6L); PNGType(chunk,mng_bKGD); LogPNGChunk(logging,mng_bKGD,6L); (void) WriteBlob(image,10,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,10)); } } #ifdef PNG_WRITE_EMPTY_PLTE_SUPPORTED if ((need_local_plte == MagickFalse) && (image->storage_class == PseudoClass) && (all_images_are_gray == MagickFalse)) { size_t data_length; /* Write MNG PLTE chunk */ data_length=3*image->colors; (void) WriteBlobMSBULong(image,data_length); PNGType(chunk,mng_PLTE); LogPNGChunk(logging,mng_PLTE,data_length); for (i=0; i < (ssize_t) image->colors; i++) { chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red) & 0xff; chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green) & 0xff; chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue) & 0xff; } (void) WriteBlob(image,data_length+4,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,(uInt) (data_length+4))); mng_info->have_write_global_plte=MagickTrue; } #endif } scene=0; mng_info->delay=0; #if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_MNG_FEATURES_SUPPORTED) mng_info->equal_palettes=MagickFalse; #endif imageListLength=GetImageListLength(image); do { if (mng_info->adjoin) { #if defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_MNG_FEATURES_SUPPORTED) /* If we aren't using a global palette for the entire MNG, check to see if we can use one for two or more consecutive images. */ if (need_local_plte && use_global_plte && !all_images_are_gray) { if (mng_info->IsPalette) { /* When equal_palettes is true, this image has the same palette as the previous PseudoClass image */ mng_info->have_write_global_plte=mng_info->equal_palettes; mng_info->equal_palettes=PalettesAreEqual(image,image->next); if (mng_info->equal_palettes && !mng_info->have_write_global_plte) { /* Write MNG PLTE chunk */ size_t data_length; data_length=3*image->colors; (void) WriteBlobMSBULong(image,data_length); PNGType(chunk,mng_PLTE); LogPNGChunk(logging,mng_PLTE,data_length); for (i=0; i < (ssize_t) image->colors; i++) { chunk[4+i*3]=ScaleQuantumToChar(image->colormap[i].red); chunk[5+i*3]=ScaleQuantumToChar(image->colormap[i].green); chunk[6+i*3]=ScaleQuantumToChar(image->colormap[i].blue); } (void) WriteBlob(image,data_length+4,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk, (uInt) (data_length+4))); mng_info->have_write_global_plte=MagickTrue; } } else mng_info->have_write_global_plte=MagickFalse; } #endif if (need_defi) { ssize_t previous_x, previous_y; if (scene != 0) { previous_x=mng_info->page.x; previous_y=mng_info->page.y; } else { previous_x=0; previous_y=0; } mng_info->page=image->page; if ((mng_info->page.x != previous_x) || (mng_info->page.y != previous_y)) { (void) WriteBlobMSBULong(image,12L); /* data length=12 */ PNGType(chunk,mng_DEFI); LogPNGChunk(logging,mng_DEFI,12L); chunk[4]=0; /* object 0 MSB */ chunk[5]=0; /* object 0 LSB */ chunk[6]=0; /* visible */ chunk[7]=0; /* abstract */ PNGLong(chunk+8,(png_uint_32) mng_info->page.x); PNGLong(chunk+12,(png_uint_32) mng_info->page.y); (void) WriteBlob(image,16,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,16)); } } } mng_info->write_mng=write_mng; if ((int) image->dispose >= 3) mng_info->framing_mode=3; if (mng_info->need_fram && mng_info->adjoin && ((image->delay != mng_info->delay) || (mng_info->framing_mode != mng_info->old_framing_mode))) { if (image->delay == mng_info->delay) { /* Write a MNG FRAM chunk with the new framing mode. */ (void) WriteBlobMSBULong(image,1L); /* data length=1 */ PNGType(chunk,mng_FRAM); LogPNGChunk(logging,mng_FRAM,1L); chunk[4]=(unsigned char) mng_info->framing_mode; (void) WriteBlob(image,5,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,5)); } else { /* Write a MNG FRAM chunk with the delay. */ (void) WriteBlobMSBULong(image,10L); /* data length=10 */ PNGType(chunk,mng_FRAM); LogPNGChunk(logging,mng_FRAM,10L); chunk[4]=(unsigned char) mng_info->framing_mode; chunk[5]=0; /* frame name separator (no name) */ chunk[6]=2; /* flag for changing default delay */ chunk[7]=0; /* flag for changing frame timeout */ chunk[8]=0; /* flag for changing frame clipping */ chunk[9]=0; /* flag for changing frame sync_id */ PNGLong(chunk+10,(png_uint_32) ((mng_info->ticks_per_second* image->delay)/MagickMax(image->ticks_per_second,1))); (void) WriteBlob(image,14,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,14)); mng_info->delay=(png_uint_32) image->delay; } mng_info->old_framing_mode=mng_info->framing_mode; } #if defined(JNG_SUPPORTED) if (image_info->compression == JPEGCompression) { ImageInfo *write_info; if (logging != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Writing JNG object."); /* To do: specify the desired alpha compression method. */ write_info=CloneImageInfo(image_info); write_info->compression=UndefinedCompression; status=WriteOneJNGImage(mng_info,write_info,image); write_info=DestroyImageInfo(write_info); } else #endif { if (logging != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " Writing PNG object."); mng_info->need_blob = MagickFalse; mng_info->ping_preserve_colormap = MagickFalse; /* We don't want any ancillary chunks written */ mng_info->ping_exclude_bKGD=MagickTrue; mng_info->ping_exclude_caNv=MagickTrue; mng_info->ping_exclude_cHRM=MagickTrue; mng_info->ping_exclude_date=MagickTrue; mng_info->ping_exclude_EXIF=MagickTrue; mng_info->ping_exclude_eXIf=MagickTrue; mng_info->ping_exclude_gAMA=MagickTrue; mng_info->ping_exclude_iCCP=MagickTrue; /* mng_info->ping_exclude_iTXt=MagickTrue; */ mng_info->ping_exclude_oFFs=MagickTrue; mng_info->ping_exclude_pHYs=MagickTrue; mng_info->ping_exclude_sRGB=MagickTrue; mng_info->ping_exclude_tEXt=MagickTrue; mng_info->ping_exclude_tRNS=MagickTrue; mng_info->ping_exclude_zCCP=MagickTrue; mng_info->ping_exclude_zTXt=MagickTrue; status=WriteOnePNGImage(mng_info,image_info,image); } if (status == MagickFalse) { mng_info=MngInfoFreeStruct(mng_info); (void) CloseBlob(image); return(MagickFalse); } (void) CatchImageException(image); if (GetNextImageInList(image) == (Image *) NULL) break; image=SyncNextImageInList(image); status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); if (status == MagickFalse) break; } while (mng_info->adjoin); if (write_mng) { while (GetPreviousImageInList(image) != (Image *) NULL) image=GetPreviousImageInList(image); /* Write the MEND chunk. */ (void) WriteBlobMSBULong(image,0x00000000L); PNGType(chunk,mng_MEND); LogPNGChunk(logging,mng_MEND,0L); (void) WriteBlob(image,4,chunk); (void) WriteBlobMSBULong(image,crc32(0,chunk,4)); } /* Relinquish resources. */ (void) CloseBlob(image); mng_info=MngInfoFreeStruct(mng_info); if (logging != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(),"exit WriteMNGImage()"); return(MagickTrue); }
0
309,484
long ContentEncoding::ParseEncryptionEntry(long long start, long long size, IMkvReader* pReader, ContentEncryption* encryption) { assert(pReader); assert(encryption); long long pos = start; const long long stop = start + size; while (pos < stop) { long long id, size; const long status = ParseElementHeader(pReader, pos, stop, id, size); if (status < 0) // error return status; if (id == 0x7E1) { encryption->algo = UnserializeUInt(pReader, pos, size); if (encryption->algo != 5) return E_FILE_FORMAT_INVALID; } else if (id == 0x7E2) { delete[] encryption->key_id; encryption->key_id = NULL; encryption->key_id_len = 0; if (size <= 0) return E_FILE_FORMAT_INVALID; const size_t buflen = static_cast<size_t>(size); unsigned char* buf = SafeArrayAlloc<unsigned char>(1, buflen); if (buf == NULL) return -1; const int read_status = pReader->Read(pos, static_cast<long>(buflen), buf); if (read_status) { delete[] buf; return status; } encryption->key_id = buf; encryption->key_id_len = buflen; } else if (id == 0x7E3) { delete[] encryption->signature; encryption->signature = NULL; encryption->signature_len = 0; if (size <= 0) return E_FILE_FORMAT_INVALID; const size_t buflen = static_cast<size_t>(size); unsigned char* buf = SafeArrayAlloc<unsigned char>(1, buflen); if (buf == NULL) return -1; const int read_status = pReader->Read(pos, static_cast<long>(buflen), buf); if (read_status) { delete[] buf; return status; } encryption->signature = buf; encryption->signature_len = buflen; } else if (id == 0x7E4) { delete[] encryption->sig_key_id; encryption->sig_key_id = NULL; encryption->sig_key_id_len = 0; if (size <= 0) return E_FILE_FORMAT_INVALID; const size_t buflen = static_cast<size_t>(size); unsigned char* buf = SafeArrayAlloc<unsigned char>(1, buflen); if (buf == NULL) return -1; const int read_status = pReader->Read(pos, static_cast<long>(buflen), buf); if (read_status) { delete[] buf; return status; } encryption->sig_key_id = buf; encryption->sig_key_id_len = buflen; } else if (id == 0x7E5) { encryption->sig_algo = UnserializeUInt(pReader, pos, size); } else if (id == 0x7E6) { encryption->sig_hash_algo = UnserializeUInt(pReader, pos, size); } else if (id == 0x7E7) { const long status = ParseContentEncAESSettingsEntry( pos, size, pReader, &encryption->aes_settings); if (status) return status; } pos += size; // consume payload if (pos > stop) return E_FILE_FORMAT_INVALID; } return 0; }
0
354,239
unsigned int X509v3_addr_get_afi(const IPAddressFamily *f) { return ((f != NULL && f->addressFamily != NULL && f->addressFamily->data != NULL) ? ((f->addressFamily->data[0] << 8) | (f->addressFamily->data[1])) : 0); }
1
458,202
void OPJ_CALLCONV opj_destroy_codec(opj_codec_t *p_codec) { if (p_codec) { opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; if (l_codec->is_decompressor) { l_codec->m_codec_data.m_decompression.opj_destroy(l_codec->m_codec); } else { l_codec->m_codec_data.m_compression.opj_destroy(l_codec->m_codec); } l_codec->m_codec = 00; opj_free(l_codec); } }
0
327,496
static void load_elf_image(const char *image_name, int image_fd, struct image_info *info, char **pinterp_name, char bprm_buf[BPRM_BUF_SIZE]) { struct elfhdr *ehdr = (struct elfhdr *)bprm_buf; struct elf_phdr *phdr; abi_ulong load_addr, load_bias, loaddr, hiaddr, error; int i, retval; const char *errmsg; /* First of all, some simple consistency checks */ errmsg = "Invalid ELF image for this architecture"; if (!elf_check_ident(ehdr)) { goto exit_errmsg; } bswap_ehdr(ehdr); if (!elf_check_ehdr(ehdr)) { goto exit_errmsg; } i = ehdr->e_phnum * sizeof(struct elf_phdr); if (ehdr->e_phoff + i <= BPRM_BUF_SIZE) { phdr = (struct elf_phdr *)(bprm_buf + ehdr->e_phoff); } else { phdr = (struct elf_phdr *) alloca(i); retval = pread(image_fd, phdr, i, ehdr->e_phoff); if (retval != i) { goto exit_read; } } bswap_phdr(phdr, ehdr->e_phnum); #ifdef CONFIG_USE_FDPIC info->nsegs = 0; info->pt_dynamic_addr = 0; #endif /* Find the maximum size of the image and allocate an appropriate amount of memory to handle that. */ loaddr = -1, hiaddr = 0; for (i = 0; i < ehdr->e_phnum; ++i) { if (phdr[i].p_type == PT_LOAD) { abi_ulong a = phdr[i].p_vaddr; if (a < loaddr) { loaddr = a; } a += phdr[i].p_memsz; if (a > hiaddr) { hiaddr = a; } #ifdef CONFIG_USE_FDPIC ++info->nsegs; #endif } } load_addr = loaddr; if (ehdr->e_type == ET_DYN) { /* The image indicates that it can be loaded anywhere. Find a location that can hold the memory space required. If the image is pre-linked, LOADDR will be non-zero. Since we do not supply MAP_FIXED here we'll use that address if and only if it remains available. */ load_addr = target_mmap(loaddr, hiaddr - loaddr, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, -1, 0); if (load_addr == -1) { goto exit_perror; } } else if (pinterp_name != NULL) { /* This is the main executable. Make sure that the low address does not conflict with MMAP_MIN_ADDR or the QEMU application itself. */ probe_guest_base(image_name, loaddr, hiaddr); } load_bias = load_addr - loaddr; #ifdef CONFIG_USE_FDPIC { struct elf32_fdpic_loadseg *loadsegs = info->loadsegs = g_malloc(sizeof(*loadsegs) * info->nsegs); for (i = 0; i < ehdr->e_phnum; ++i) { switch (phdr[i].p_type) { case PT_DYNAMIC: info->pt_dynamic_addr = phdr[i].p_vaddr + load_bias; break; case PT_LOAD: loadsegs->addr = phdr[i].p_vaddr + load_bias; loadsegs->p_vaddr = phdr[i].p_vaddr; loadsegs->p_memsz = phdr[i].p_memsz; ++loadsegs; break; } } } #endif info->load_bias = load_bias; info->load_addr = load_addr; info->entry = ehdr->e_entry + load_bias; info->start_code = -1; info->end_code = 0; info->start_data = -1; info->end_data = 0; info->brk = 0; for (i = 0; i < ehdr->e_phnum; i++) { struct elf_phdr *eppnt = phdr + i; if (eppnt->p_type == PT_LOAD) { abi_ulong vaddr, vaddr_po, vaddr_ps, vaddr_ef, vaddr_em; int elf_prot = 0; if (eppnt->p_flags & PF_R) elf_prot = PROT_READ; if (eppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; if (eppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; vaddr = load_bias + eppnt->p_vaddr; vaddr_po = TARGET_ELF_PAGEOFFSET(vaddr); vaddr_ps = TARGET_ELF_PAGESTART(vaddr); error = target_mmap(vaddr_ps, eppnt->p_filesz + vaddr_po, elf_prot, MAP_PRIVATE | MAP_FIXED, image_fd, eppnt->p_offset - vaddr_po); if (error == -1) { goto exit_perror; } vaddr_ef = vaddr + eppnt->p_filesz; vaddr_em = vaddr + eppnt->p_memsz; /* If the load segment requests extra zeros (e.g. bss), map it. */ if (vaddr_ef < vaddr_em) { zero_bss(vaddr_ef, vaddr_em, elf_prot); } /* Find the full program boundaries. */ if (elf_prot & PROT_EXEC) { if (vaddr < info->start_code) { info->start_code = vaddr; } if (vaddr_ef > info->end_code) { info->end_code = vaddr_ef; } } if (elf_prot & PROT_WRITE) { if (vaddr < info->start_data) { info->start_data = vaddr; } if (vaddr_ef > info->end_data) { info->end_data = vaddr_ef; } if (vaddr_em > info->brk) { info->brk = vaddr_em; } } } else if (eppnt->p_type == PT_INTERP && pinterp_name) { char *interp_name; if (*pinterp_name) { errmsg = "Multiple PT_INTERP entries"; goto exit_errmsg; } interp_name = malloc(eppnt->p_filesz); if (!interp_name) { goto exit_perror; } if (eppnt->p_offset + eppnt->p_filesz <= BPRM_BUF_SIZE) { memcpy(interp_name, bprm_buf + eppnt->p_offset, eppnt->p_filesz); } else { retval = pread(image_fd, interp_name, eppnt->p_filesz, eppnt->p_offset); if (retval != eppnt->p_filesz) { goto exit_perror; } } if (interp_name[eppnt->p_filesz - 1] != 0) { errmsg = "Invalid PT_INTERP entry"; goto exit_errmsg; } *pinterp_name = interp_name; } } if (info->end_data == 0) { info->start_data = info->end_code; info->end_data = info->end_code; info->brk = info->end_code; } if (qemu_log_enabled()) { load_symbols(ehdr, image_fd, load_bias); } close(image_fd); return; exit_read: if (retval >= 0) { errmsg = "Incomplete read of file header"; goto exit_errmsg; } exit_perror: errmsg = strerror(errno); exit_errmsg: fprintf(stderr, "%s: %s\n", image_name, errmsg); exit(-1); }
1
246,702
bool DevToolsWindow::ReloadInspectedWebContents(bool bypass_cache) { WebContents* wc = GetInspectedWebContents(); if (!wc || wc->GetCrashedStatus() != base::TERMINATION_STATUS_STILL_RUNNING) return false; base::FundamentalValue bypass_cache_value(bypass_cache); bindings_->CallClientFunction("DevToolsAPI.reloadInspectedPage", &bypass_cache_value, nullptr, nullptr); return true; }
0
349,261
bool MasteringMetadata::Write(IMkvWriter* writer) const { const uint64_t size = PayloadSize(); // Don't write an empty element. if (size == 0) return true; if (!WriteEbmlMasterElement(writer, libwebm::kMkvMasteringMetadata, size)) return false; if (luminance_max_ != kValueNotPresent && !WriteEbmlElement(writer, libwebm::kMkvLuminanceMax, luminance_max_)) { return false; } if (luminance_min_ != kValueNotPresent && !WriteEbmlElement(writer, libwebm::kMkvLuminanceMin, luminance_min_)) { return false; } if (r_ && !r_->Write(writer, libwebm::kMkvPrimaryRChromaticityX, libwebm::kMkvPrimaryRChromaticityY)) { return false; } if (g_ && !g_->Write(writer, libwebm::kMkvPrimaryGChromaticityX, libwebm::kMkvPrimaryGChromaticityY)) { return false; } if (b_ && !b_->Write(writer, libwebm::kMkvPrimaryBChromaticityX, libwebm::kMkvPrimaryBChromaticityY)) { return false; } if (white_point_ && !white_point_->Write(writer, libwebm::kMkvWhitePointChromaticityX, libwebm::kMkvWhitePointChromaticityY)) { return false; } return true; }
1
288,773
static void test_bug10794 ( ) { MYSQL_STMT * stmt , * stmt1 ; MYSQL_BIND my_bind [ 2 ] ; char a [ 21 ] ; int id_val ; ulong a_len ; int rc ; const char * stmt_text ; int i = 0 ; ulong type ; myheader ( "test_bug10794" ) ; mysql_query ( mysql , "drop table if exists t1" ) ; mysql_query ( mysql , "create table t1 (id integer not null primary key," "name varchar(20) not null)" ) ; stmt = mysql_stmt_init ( mysql ) ; stmt_text = "insert into t1 (id, name) values (?, ?)" ; rc = mysql_stmt_prepare ( stmt , stmt_text , strlen ( stmt_text ) ) ; check_execute ( stmt , rc ) ; memset ( my_bind , 0 , sizeof ( my_bind ) ) ; my_bind [ 0 ] . buffer_type = MYSQL_TYPE_LONG ; my_bind [ 0 ] . buffer = ( void * ) & id_val ; my_bind [ 1 ] . buffer_type = MYSQL_TYPE_STRING ; my_bind [ 1 ] . buffer = ( void * ) a ; my_bind [ 1 ] . length = & a_len ; rc = mysql_stmt_bind_param ( stmt , my_bind ) ; check_execute ( stmt , rc ) ; for ( i = 0 ; i < 42 ; i ++ ) { id_val = ( i + 1 ) * 10 ; sprintf ( a , "a%d" , i ) ; a_len = strlen ( a ) ; rc = mysql_stmt_execute ( stmt ) ; check_execute ( stmt , rc ) ; } stmt_text = "select name from t1" ; rc = mysql_stmt_prepare ( stmt , stmt_text , strlen ( stmt_text ) ) ; type = ( ulong ) CURSOR_TYPE_READ_ONLY ; mysql_stmt_attr_set ( stmt , STMT_ATTR_CURSOR_TYPE , ( const void * ) & type ) ; stmt1 = mysql_stmt_init ( mysql ) ; mysql_stmt_attr_set ( stmt1 , STMT_ATTR_CURSOR_TYPE , ( const void * ) & type ) ; memset ( my_bind , 0 , sizeof ( my_bind ) ) ; my_bind [ 0 ] . buffer_type = MYSQL_TYPE_STRING ; my_bind [ 0 ] . buffer = ( void * ) a ; my_bind [ 0 ] . buffer_length = sizeof ( a ) ; my_bind [ 0 ] . length = & a_len ; rc = mysql_stmt_bind_result ( stmt , my_bind ) ; check_execute ( stmt , rc ) ; rc = mysql_stmt_execute ( stmt ) ; check_execute ( stmt , rc ) ; rc = mysql_stmt_fetch ( stmt ) ; check_execute ( stmt , rc ) ; if ( ! opt_silent ) printf ( "Fetched row from stmt: %s\n" , a ) ; mysql_stmt_free_result ( stmt ) ; mysql_stmt_reset ( stmt ) ; stmt_text = "select name from t1 where id=10" ; rc = mysql_stmt_prepare ( stmt1 , stmt_text , strlen ( stmt_text ) ) ; check_execute ( stmt1 , rc ) ; rc = mysql_stmt_bind_result ( stmt1 , my_bind ) ; check_execute ( stmt1 , rc ) ; rc = mysql_stmt_execute ( stmt1 ) ; while ( 1 ) { rc = mysql_stmt_fetch ( stmt1 ) ; if ( rc == MYSQL_NO_DATA ) { if ( ! opt_silent ) printf ( "End of data in stmt1\n" ) ; break ; } check_execute ( stmt1 , rc ) ; if ( ! opt_silent ) printf ( "Fetched row from stmt1: %s\n" , a ) ; } mysql_stmt_close ( stmt ) ; mysql_stmt_close ( stmt1 ) ; rc = mysql_query ( mysql , "drop table t1" ) ; myquery ( rc ) ; }
0
210,867
void ChromeDownloadManagerDelegate::AddItemToPersistentStore( DownloadItem* item) { download_history_->AddEntry(item, base::Bind(&ChromeDownloadManagerDelegate::OnItemAddedToPersistentStore, base::Unretained(this))); }
0
250,365
size_t GetUTF8Offset(const std::wstring& wide_text, size_t wide_text_offset) { return WideToUTF8(wide_text.substr(0, wide_text_offset)).size(); }
0
423,737
dns_zone_getraw(dns_zone_t *zone, dns_zone_t **raw) { REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(raw != NULL && *raw == NULL); LOCK(&zone->lock); INSIST(zone != zone->raw); if (zone->raw != NULL) dns_zone_attach(zone->raw, raw); UNLOCK(&zone->lock); }
0
423,436
zone_check_mx(dns_zone_t *zone, dns_db_t *db, dns_name_t *name, dns_name_t *owner) { isc_result_t result; char ownerbuf[DNS_NAME_FORMATSIZE]; char namebuf[DNS_NAME_FORMATSIZE]; char altbuf[DNS_NAME_FORMATSIZE]; dns_fixedname_t fixed; dns_name_t *foundname; int level; /* * "." means the services does not exist. */ if (dns_name_equal(name, dns_rootname)) return (true); /* * Outside of zone. */ if (!dns_name_issubdomain(name, &zone->origin)) { if (zone->checkmx != NULL) return ((zone->checkmx)(zone, name, owner)); return (true); } if (zone->type == dns_zone_master) level = ISC_LOG_ERROR; else level = ISC_LOG_WARNING; foundname = dns_fixedname_initname(&fixed); result = dns_db_find(db, name, NULL, dns_rdatatype_a, 0, 0, NULL, foundname, NULL, NULL); if (result == ISC_R_SUCCESS) return (true); if (result == DNS_R_NXRRSET) { result = dns_db_find(db, name, NULL, dns_rdatatype_aaaa, 0, 0, NULL, foundname, NULL, NULL); if (result == ISC_R_SUCCESS) return (true); } dns_name_format(owner, ownerbuf, sizeof ownerbuf); dns_name_format(name, namebuf, sizeof namebuf); if (result == DNS_R_NXRRSET || result == DNS_R_NXDOMAIN || result == DNS_R_EMPTYNAME) { if (!DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKMXFAIL)) level = ISC_LOG_WARNING; dns_zone_log(zone, level, "%s/MX '%s' has no address records (A or AAAA)", ownerbuf, namebuf); return ((level == ISC_LOG_WARNING) ? true : false); } if (result == DNS_R_CNAME) { if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_WARNMXCNAME) || DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IGNOREMXCNAME)) level = ISC_LOG_WARNING; if (!DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IGNOREMXCNAME)) dns_zone_log(zone, level, "%s/MX '%s' is a CNAME (illegal)", ownerbuf, namebuf); return ((level == ISC_LOG_WARNING) ? true : false); } if (result == DNS_R_DNAME) { if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_WARNMXCNAME) || DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IGNOREMXCNAME)) level = ISC_LOG_WARNING; if (!DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IGNOREMXCNAME)) { dns_name_format(foundname, altbuf, sizeof altbuf); dns_zone_log(zone, level, "%s/MX '%s' is below a DNAME" " '%s' (illegal)", ownerbuf, namebuf, altbuf); } return ((level == ISC_LOG_WARNING) ? true : false); } if (zone->checkmx != NULL && result == DNS_R_DELEGATION) return ((zone->checkmx)(zone, name, owner)); return (true); }
0
188,965
is_hex(const char *p, size_t len) { while (len-- > 0) { if ((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')) ++p; else return (0); } return (1); }
0
437,635
static int spl_filesystem_dir_it_valid(zend_object_iterator *iter) { spl_filesystem_object *object = spl_filesystem_iterator_to_object((spl_filesystem_iterator *)iter); return object->u.dir.entry.d_name[0] != '\0' ? SUCCESS : FAILURE; }
0
324,473
int attribute_align_arg sws_scale(struct SwsContext *c, const uint8_t * const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[]) { int i, ret; const uint8_t *src2[4] = { srcSlice[0], srcSlice[1], srcSlice[2], srcSlice[3] }; uint8_t *dst2[4] = { dst[0], dst[1], dst[2], dst[3] }; uint8_t *rgb0_tmp = NULL; // do not mess up sliceDir if we have a "trailing" 0-size slice if (srcSliceH == 0) return 0; if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) { av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); return 0; } if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) { av_log(c, AV_LOG_ERROR, "bad dst image pointers\n"); return 0; } if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); return 0; } if (c->sliceDir == 0) { if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1; } if (usePal(c->srcFormat)) { for (i = 0; i < 256; i++) { int p, r, g, b, y, u, v, a = 0xff; if (c->srcFormat == AV_PIX_FMT_PAL8) { p = ((const uint32_t *)(srcSlice[1]))[i]; a = (p >> 24) & 0xFF; r = (p >> 16) & 0xFF; g = (p >> 8) & 0xFF; b = p & 0xFF; } else if (c->srcFormat == AV_PIX_FMT_RGB8) { r = ( i >> 5 ) * 36; g = ((i >> 2) & 7) * 36; b = ( i & 3) * 85; } else if (c->srcFormat == AV_PIX_FMT_BGR8) { b = ( i >> 6 ) * 85; g = ((i >> 3) & 7) * 36; r = ( i & 7) * 36; } else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) { r = ( i >> 3 ) * 255; g = ((i >> 1) & 3) * 85; b = ( i & 1) * 255; } else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) { r = g = b = i; } else { av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE); b = ( i >> 3 ) * 255; g = ((i >> 1) & 3) * 85; r = ( i & 1) * 255; } #define RGB2YUV_SHIFT 15 #define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); c->pal_yuv[i]= y + (u<<8) + (v<<16) + ((unsigned)a<<24); switch (c->dstFormat) { case AV_PIX_FMT_BGR32: #if !HAVE_BIGENDIAN case AV_PIX_FMT_RGB24: #endif c->pal_rgb[i]= r + (g<<8) + (b<<16) + ((unsigned)a<<24); break; case AV_PIX_FMT_BGR32_1: #if HAVE_BIGENDIAN case AV_PIX_FMT_BGR24: #endif c->pal_rgb[i]= a + (r<<8) + (g<<16) + ((unsigned)b<<24); break; case AV_PIX_FMT_RGB32_1: #if HAVE_BIGENDIAN case AV_PIX_FMT_RGB24: #endif c->pal_rgb[i]= a + (b<<8) + (g<<16) + ((unsigned)r<<24); break; case AV_PIX_FMT_RGB32: #if !HAVE_BIGENDIAN case AV_PIX_FMT_BGR24: #endif default: c->pal_rgb[i]= b + (g<<8) + (r<<16) + ((unsigned)a<<24); } } } if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) { uint8_t *base; int x,y; rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32); base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp; for (y=0; y<srcSliceH; y++){ memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->srcW); for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) { base[ srcStride[0]*y + x] = 0xFF; } } src2[0] = base; } // copy strides, so they can safely be modified if (c->sliceDir == 1) { // slices go from top to bottom int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2], srcStride[3] }; int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2], dstStride[3] }; reset_ptr(src2, c->srcFormat); reset_ptr((void*)dst2, c->dstFormat); /* reset slice direction at end of frame */ if (srcSliceY + srcSliceH == c->srcH) c->sliceDir = 0; ret = c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2, dstStride2); } else { // slices go from bottom to top => we flip the image internally int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2], -srcStride[3] }; int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2], -dstStride[3] }; src2[0] += (srcSliceH - 1) * srcStride[0]; if (!usePal(c->srcFormat)) src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1]; src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2]; src2[3] += (srcSliceH - 1) * srcStride[3]; dst2[0] += ( c->dstH - 1) * dstStride[0]; dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1]; dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2]; dst2[3] += ( c->dstH - 1) * dstStride[3]; reset_ptr(src2, c->srcFormat); reset_ptr((void*)dst2, c->dstFormat); /* reset slice direction at end of frame */ if (!srcSliceY) c->sliceDir = 0; ret = c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH, srcSliceH, dst2, dstStride2); } av_free(rgb0_tmp); return ret; }
0
175,217
FT_Stream_TryRead( FT_Stream stream, FT_Byte* buffer, FT_ULong count ) { FT_ULong read_bytes = 0; if ( stream->pos >= stream->size ) goto Exit; if ( stream->read ) read_bytes = stream->read( stream, stream->pos, buffer, count ); else { read_bytes = stream->size - stream->pos; if ( read_bytes > count ) read_bytes = count; FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes ); } stream->pos += read_bytes; Exit: return read_bytes; }
0
236,085
static OPJ_BOOL bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header) { memset(header, 0, sizeof(*header)); /* INFO HEADER */ /* ------------- */ header->biSize = (OPJ_UINT32)getc(IN); header->biSize |= (OPJ_UINT32)getc(IN) << 8; header->biSize |= (OPJ_UINT32)getc(IN) << 16; header->biSize |= (OPJ_UINT32)getc(IN) << 24; switch (header->biSize) { case 12U: /* BITMAPCOREHEADER */ case 40U: /* BITMAPINFOHEADER */ case 52U: /* BITMAPV2INFOHEADER */ case 56U: /* BITMAPV3INFOHEADER */ case 108U: /* BITMAPV4HEADER */ case 124U: /* BITMAPV5HEADER */ break; default: fprintf(stderr,"Error, unknown BMP header size %d\n", header->biSize); return OPJ_FALSE; } header->biWidth = (OPJ_UINT32)getc(IN); header->biWidth |= (OPJ_UINT32)getc(IN) << 8; header->biWidth |= (OPJ_UINT32)getc(IN) << 16; header->biWidth |= (OPJ_UINT32)getc(IN) << 24; header->biHeight = (OPJ_UINT32)getc(IN); header->biHeight |= (OPJ_UINT32)getc(IN) << 8; header->biHeight |= (OPJ_UINT32)getc(IN) << 16; header->biHeight |= (OPJ_UINT32)getc(IN) << 24; header->biPlanes = (OPJ_UINT16)getc(IN); header->biPlanes |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8); header->biBitCount = (OPJ_UINT16)getc(IN); header->biBitCount |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8); if(header->biSize >= 40U) { header->biCompression = (OPJ_UINT32)getc(IN); header->biCompression |= (OPJ_UINT32)getc(IN) << 8; header->biCompression |= (OPJ_UINT32)getc(IN) << 16; header->biCompression |= (OPJ_UINT32)getc(IN) << 24; header->biSizeImage = (OPJ_UINT32)getc(IN); header->biSizeImage |= (OPJ_UINT32)getc(IN) << 8; header->biSizeImage |= (OPJ_UINT32)getc(IN) << 16; header->biSizeImage |= (OPJ_UINT32)getc(IN) << 24; header->biXpelsPerMeter = (OPJ_UINT32)getc(IN); header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 8; header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 16; header->biXpelsPerMeter |= (OPJ_UINT32)getc(IN) << 24; header->biYpelsPerMeter = (OPJ_UINT32)getc(IN); header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 8; header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 16; header->biYpelsPerMeter |= (OPJ_UINT32)getc(IN) << 24; header->biClrUsed = (OPJ_UINT32)getc(IN); header->biClrUsed |= (OPJ_UINT32)getc(IN) << 8; header->biClrUsed |= (OPJ_UINT32)getc(IN) << 16; header->biClrUsed |= (OPJ_UINT32)getc(IN) << 24; header->biClrImportant = (OPJ_UINT32)getc(IN); header->biClrImportant |= (OPJ_UINT32)getc(IN) << 8; header->biClrImportant |= (OPJ_UINT32)getc(IN) << 16; header->biClrImportant |= (OPJ_UINT32)getc(IN) << 24; } if(header->biSize >= 56U) { header->biRedMask = (OPJ_UINT32)getc(IN); header->biRedMask |= (OPJ_UINT32)getc(IN) << 8; header->biRedMask |= (OPJ_UINT32)getc(IN) << 16; header->biRedMask |= (OPJ_UINT32)getc(IN) << 24; header->biGreenMask = (OPJ_UINT32)getc(IN); header->biGreenMask |= (OPJ_UINT32)getc(IN) << 8; header->biGreenMask |= (OPJ_UINT32)getc(IN) << 16; header->biGreenMask |= (OPJ_UINT32)getc(IN) << 24; header->biBlueMask = (OPJ_UINT32)getc(IN); header->biBlueMask |= (OPJ_UINT32)getc(IN) << 8; header->biBlueMask |= (OPJ_UINT32)getc(IN) << 16; header->biBlueMask |= (OPJ_UINT32)getc(IN) << 24; header->biAlphaMask = (OPJ_UINT32)getc(IN); header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 8; header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 16; header->biAlphaMask |= (OPJ_UINT32)getc(IN) << 24; } if(header->biSize >= 108U) { header->biColorSpaceType = (OPJ_UINT32)getc(IN); header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 8; header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 16; header->biColorSpaceType |= (OPJ_UINT32)getc(IN) << 24; if (fread(&(header->biColorSpaceEP), 1U, sizeof(header->biColorSpaceEP), IN) != sizeof(header->biColorSpaceEP)) { fprintf(stderr,"Error, can't read BMP header\n"); return OPJ_FALSE; } header->biRedGamma = (OPJ_UINT32)getc(IN); header->biRedGamma |= (OPJ_UINT32)getc(IN) << 8; header->biRedGamma |= (OPJ_UINT32)getc(IN) << 16; header->biRedGamma |= (OPJ_UINT32)getc(IN) << 24; header->biGreenGamma = (OPJ_UINT32)getc(IN); header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 8; header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 16; header->biGreenGamma |= (OPJ_UINT32)getc(IN) << 24; header->biBlueGamma = (OPJ_UINT32)getc(IN); header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 8; header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 16; header->biBlueGamma |= (OPJ_UINT32)getc(IN) << 24; } if(header->biSize >= 124U) { header->biIntent = (OPJ_UINT32)getc(IN); header->biIntent |= (OPJ_UINT32)getc(IN) << 8; header->biIntent |= (OPJ_UINT32)getc(IN) << 16; header->biIntent |= (OPJ_UINT32)getc(IN) << 24; header->biIccProfileData = (OPJ_UINT32)getc(IN); header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 8; header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 16; header->biIccProfileData |= (OPJ_UINT32)getc(IN) << 24; header->biIccProfileSize = (OPJ_UINT32)getc(IN); header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 8; header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 16; header->biIccProfileSize |= (OPJ_UINT32)getc(IN) << 24; header->biReserved = (OPJ_UINT32)getc(IN); header->biReserved |= (OPJ_UINT32)getc(IN) << 8; header->biReserved |= (OPJ_UINT32)getc(IN) << 16; header->biReserved |= (OPJ_UINT32)getc(IN) << 24; } return OPJ_TRUE; }
0
277,361
v8::Handle<v8::Value> V8ThrowException::createReferenceError(v8::Isolate* isolate, const String& message) { return v8::Exception::ReferenceError(v8String(isolate, message.isNull() ? "Reference error" : message)); }
0
203,401
void TabSpecificContentSettings::AddBlockedResource( ContentSettingsType content_type, const std::string& resource_identifier) { if (!blocked_resources_[content_type].get()) blocked_resources_[content_type].reset(new std::set<std::string>()); blocked_resources_[content_type]->insert(resource_identifier); }
0
468,441
virNodeDevCapMdevTypesParseXML(xmlXPathContextPtr ctxt, virMediatedDeviceTypePtr **mdev_types, size_t *nmdev_types) { int ret = -1; xmlNodePtr orignode = NULL; xmlNodePtr *nodes = NULL; int ntypes = -1; virMediatedDeviceTypePtr type = NULL; size_t i; if ((ntypes = virXPathNodeSet("./type", ctxt, &nodes)) < 0) goto cleanup; if (nmdev_types == 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing <type> element in <capability> element")); goto cleanup; } orignode = ctxt->node; for (i = 0; i < ntypes; i++) { ctxt->node = nodes[i]; type = g_new0(virMediatedDeviceType, 1); if (!(type->id = virXPathString("string(./@id[1])", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing 'id' attribute for mediated device's " "<type> element")); goto cleanup; } if (!(type->device_api = virXPathString("string(./deviceAPI[1])", ctxt))) { virReportError(VIR_ERR_XML_ERROR, _("missing device API for mediated device type '%s'"), type->id); goto cleanup; } if (virXPathUInt("number(./availableInstances)", ctxt, &type->available_instances) < 0) { virReportError(VIR_ERR_XML_ERROR, _("missing number of available instances for " "mediated device type '%s'"), type->id); goto cleanup; } type->name = virXPathString("string(./name)", ctxt); if (VIR_APPEND_ELEMENT(*mdev_types, *nmdev_types, type) < 0) goto cleanup; } ret = 0; cleanup: VIR_FREE(nodes); virMediatedDeviceTypeFree(type); ctxt->node = orignode; return ret; }
0
327,704
static int dxtory_decode_v2_rgb(AVCodecContext *avctx, AVFrame *pic, const uint8_t *src, int src_size) { GetByteContext gb; GetBitContext gb2; int nslices, slice, slice_height; uint32_t off, slice_size; uint8_t *dst; int ret; bytestream2_init(&gb, src, src_size); nslices = bytestream2_get_le16(&gb); off = FFALIGN(nslices * 4 + 2, 16); if (src_size < off) { av_log(avctx, AV_LOG_ERROR, "no slice data\n"); return AVERROR_INVALIDDATA; } if (!nslices || avctx->height % nslices) { avpriv_request_sample(avctx, "%d slices for %dx%d", nslices, avctx->width, avctx->height); return AVERROR_PATCHWELCOME; } slice_height = avctx->height / nslices; avctx->pix_fmt = AV_PIX_FMT_BGR24; if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) return ret; dst = pic->data[0]; for (slice = 0; slice < nslices; slice++) { slice_size = bytestream2_get_le32(&gb); if (slice_size > src_size - off) { av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32" (only %"PRIu32" bytes left)\n", slice_size, src_size - off); return AVERROR_INVALIDDATA; } if (slice_size <= 16) { av_log(avctx, AV_LOG_ERROR, "invalid slice size %"PRIu32"\n", slice_size); return AVERROR_INVALIDDATA; } if (AV_RL32(src + off) != slice_size - 16) { av_log(avctx, AV_LOG_ERROR, "Slice sizes mismatch: got %"PRIu32" instead of %"PRIu32"\n", AV_RL32(src + off), slice_size - 16); } init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8); dx2_decode_slice_rgb(&gb2, avctx->width, slice_height, dst, pic->linesize[0]); dst += pic->linesize[0] * slice_height; off += slice_size; } return 0; }
0
201,773
void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg) { struct proxy *fe = strm_fe(s); int tmp = TX_CON_WANT_KAL; if (!((fe->options2|s->be->options2) & PR_O2_FAKE_KA)) { if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN || (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN) tmp = TX_CON_WANT_TUN; if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL || (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL) tmp = TX_CON_WANT_TUN; } if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL || (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL) { /* option httpclose + server_close => forceclose */ if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL || (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL) tmp = TX_CON_WANT_CLO; else tmp = TX_CON_WANT_SCL; } if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL || (s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL) tmp = TX_CON_WANT_CLO; if ((txn->flags & TX_CON_WANT_MSK) < tmp) txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | tmp; if (!(txn->flags & TX_HDR_CONN_PRS) && (txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) { /* parse the Connection header and possibly clean it */ int to_del = 0; if ((msg->flags & HTTP_MSGF_VER_11) || ((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL && !((fe->options2|s->be->options2) & PR_O2_FAKE_KA))) to_del |= 2; /* remove "keep-alive" */ if (!(msg->flags & HTTP_MSGF_VER_11)) to_del |= 1; /* remove "close" */ http_parse_connection_header(txn, msg, to_del); } /* check if client or config asks for explicit close in KAL/SCL */ if (((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL || (txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) && ((txn->flags & TX_HDR_CONN_CLO) || /* "connection: close" */ (!(msg->flags & HTTP_MSGF_VER_11) && !(txn->flags & TX_HDR_CONN_KAL)) || /* no "connection: k-a" in 1.0 */ !(msg->flags & HTTP_MSGF_XFER_LEN) || /* no length known => close */ fe->state == PR_STSTOPPED)) /* frontend is stopping */ txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO; }
0
104,307
static int tg_set_bandwidth(struct task_group *tg, u64 rt_period, u64 rt_runtime) { int i, err = 0; mutex_lock(&rt_constraints_mutex); read_lock(&tasklist_lock); err = __rt_schedulable(tg, rt_period, rt_runtime); if (err) goto unlock; raw_spin_lock_irq(&tg->rt_bandwidth.rt_runtime_lock); tg->rt_bandwidth.rt_period = ns_to_ktime(rt_period); tg->rt_bandwidth.rt_runtime = rt_runtime; for_each_possible_cpu(i) { struct rt_rq *rt_rq = tg->rt_rq[i]; raw_spin_lock(&rt_rq->rt_runtime_lock); rt_rq->rt_runtime = rt_runtime; raw_spin_unlock(&rt_rq->rt_runtime_lock); } raw_spin_unlock_irq(&tg->rt_bandwidth.rt_runtime_lock); unlock: read_unlock(&tasklist_lock); mutex_unlock(&rt_constraints_mutex); return err; }
0
19,275
fz_colorspace * fz_keep_colorspace ( fz_context * ctx , fz_colorspace * cs ) { return fz_keep_key_storable ( ctx , & cs -> key_storable ) ; }
0
300,826
static int common_perm_rm(int op, struct path *dir, struct dentry *dentry, u32 mask) { struct inode *inode = dentry->d_inode; struct path_cond cond = { }; if (!inode || !dir->mnt || !mediated_filesystem(inode)) return 0; cond.uid = inode->i_uid; cond.mode = inode->i_mode; return common_perm_dir_dentry(op, dir, dentry, mask, &cond); }
0
461,070
static MemTxResult gic_hyp_read(void *opaque, int cpu, hwaddr addr, uint64_t *data, MemTxAttrs attrs) { GICState *s = ARM_GIC(opaque); int vcpu = cpu + GIC_NCPU; switch (addr) { case A_GICH_HCR: /* Hypervisor Control */ *data = s->h_hcr[cpu]; break; case A_GICH_VTR: /* VGIC Type */ *data = FIELD_DP32(0, GICH_VTR, ListRegs, s->num_lrs - 1); *data = FIELD_DP32(*data, GICH_VTR, PREbits, GIC_VIRT_MAX_GROUP_PRIO_BITS - 1); *data = FIELD_DP32(*data, GICH_VTR, PRIbits, (7 - GIC_VIRT_MIN_BPR) - 1); break; case A_GICH_VMCR: /* Virtual Machine Control */ *data = FIELD_DP32(0, GICH_VMCR, VMCCtlr, extract32(s->cpu_ctlr[vcpu], 0, 10)); *data = FIELD_DP32(*data, GICH_VMCR, VMABP, s->abpr[vcpu]); *data = FIELD_DP32(*data, GICH_VMCR, VMBP, s->bpr[vcpu]); *data = FIELD_DP32(*data, GICH_VMCR, VMPriMask, extract32(s->priority_mask[vcpu], 3, 5)); break; case A_GICH_MISR: /* Maintenance Interrupt Status */ *data = s->h_misr[cpu]; break; case A_GICH_EISR0: /* End of Interrupt Status 0 and 1 */ case A_GICH_EISR1: *data = gic_compute_eisr(s, cpu, (addr - A_GICH_EISR0) * 8); break; case A_GICH_ELRSR0: /* Empty List Status 0 and 1 */ case A_GICH_ELRSR1: *data = gic_compute_elrsr(s, cpu, (addr - A_GICH_ELRSR0) * 8); break; case A_GICH_APR: /* Active Priorities */ *data = s->h_apr[cpu]; break; case A_GICH_LR0 ... A_GICH_LR63: /* List Registers */ { int lr_idx = (addr - A_GICH_LR0) / 4; if (lr_idx > s->num_lrs) { *data = 0; } else { *data = s->h_lr[lr_idx][cpu]; } break; } default: qemu_log_mask(LOG_GUEST_ERROR, "gic_hyp_read: Bad offset %" HWADDR_PRIx "\n", addr); return MEMTX_OK; } trace_gic_hyp_read(addr, *data); return MEMTX_OK; }
0
258,091
static void parse_context_init ( SchroParseUnitContext * parse_ctx , const uint8_t * buf , int buf_size ) { parse_ctx -> buf = buf ; parse_ctx -> buf_size = buf_size ; }
0
284,421
void GLES2Implementation::EnableVertexAttribArray(GLuint index) { GPU_CLIENT_SINGLE_THREAD_CHECK(); GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glEnableVertexAttribArray(" << index << ")"); vertex_array_object_manager_->SetAttribEnable(index, true); helper_->EnableVertexAttribArray(index); CheckGLError(); }
0
355,449
ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) { struct ip_tunnel_prl_entry *x, **p; int err = 0; write_lock(&ipip6_lock); if (a && a->addr != htonl(INADDR_ANY)) { for (p = &t->prl; *p; p = &(*p)->next) { if ((*p)->addr == a->addr) { x = *p; *p = x->next; kfree(x); t->prl_count--; goto out; } } err = -ENXIO; } else { while (t->prl) { x = t->prl; t->prl = t->prl->next; kfree(x); t->prl_count--; } } out: write_unlock(&ipip6_lock); return 0; }
0
514,092
while_command() { int do_start, do_end; char *clause; int save_token, end_token; double exprval; c_token++; save_token = c_token; exprval = real_expression(); if (!equals(c_token,"{")) int_error(c_token,"expecting {while-clause}"); end_token = find_clause(&do_start, &do_end); clause = new_clause(do_start, do_end); begin_clause(); iteration_depth++; while (exprval != 0) { requested_continue = FALSE; do_string(clause); if (command_exit_requested) requested_break = TRUE; if (requested_break) break; c_token = save_token; exprval = real_expression(); }; iteration_depth--; end_clause(); free(clause); c_token = end_token; requested_break = FALSE; requested_continue = FALSE; }
0
42,009
int ha_myisam::index_read_map(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) { MYSQL_INDEX_READ_ROW_START(table_share->db.str, table_share->table_name.str); DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_key_count); int error=mi_rkey(file, buf, active_index, key, keypart_map, find_flag); table->status=error ? STATUS_NOT_FOUND: 0; MYSQL_INDEX_READ_ROW_DONE(error); return error; }
0
225,030
void GfxCalRGBColorSpace::getGray(GfxColor *color, GfxGray *gray) { GfxRGB rgb; #ifdef USE_CMS if (XYZ2DisplayTransform != NULL && displayPixelType == PT_GRAY) { Guchar out[gfxColorMaxComps]; double in[gfxColorMaxComps]; double X, Y, Z; getXYZ(color,&X,&Y,&Z); in[0] = clip01(X); in[1] = clip01(Y); in[2] = clip01(Z); XYZ2DisplayTransform->doTransform(in,out,1); *gray = byteToCol(out[0]); return; } #endif getRGB(color, &rgb); *gray = clip01((GfxColorComp)(0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b + 0.5)); }
0
485,861
sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const sctp_subtype_t type, void *arg, sctp_cmd_seq_t *commands) { struct sctp_chunk *chunk = arg; sctp_shutdownhdr_t *sdh; sctp_disposition_t disposition; struct sctp_ulpevent *ev; if (!sctp_vtag_verify(chunk, asoc)) return sctp_sf_pdiscard(ep, asoc, type, arg, commands); /* Make sure that the SHUTDOWN chunk has a valid length. */ if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk_t))) return sctp_sf_violation_chunklen(ep, asoc, type, arg, commands); /* Convert the elaborate header. */ sdh = (sctp_shutdownhdr_t *)chunk->skb->data; skb_pull(chunk->skb, sizeof(sctp_shutdownhdr_t)); chunk->subh.shutdown_hdr = sdh; /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT * When a peer sends a SHUTDOWN, SCTP delivers this notification to * inform the application that it should cease sending data. */ ev = sctp_ulpevent_make_shutdown_event(asoc, 0, GFP_ATOMIC); if (!ev) { disposition = SCTP_DISPOSITION_NOMEM; goto out; } sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); /* Upon the reception of the SHUTDOWN, the peer endpoint shall * - enter the SHUTDOWN-RECEIVED state, * - stop accepting new data from its SCTP user * * [This is implicit in the new state.] */ sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, SCTP_STATE(SCTP_STATE_SHUTDOWN_RECEIVED)); disposition = SCTP_DISPOSITION_CONSUME; if (sctp_outq_is_empty(&asoc->outqueue)) { disposition = sctp_sf_do_9_2_shutdown_ack(ep, asoc, type, arg, commands); } if (SCTP_DISPOSITION_NOMEM == disposition) goto out; /* - verify, by checking the Cumulative TSN Ack field of the * chunk, that all its outstanding DATA chunks have been * received by the SHUTDOWN sender. */ sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN, SCTP_U32(chunk->subh.shutdown_hdr->cum_tsn_ack)); out: return disposition; }
0
263,784
bool HHVM_FUNCTION(hash_equals, const Variant& known, const Variant& user) { if (!known.isString()) { raise_warning( "hash_equals(): Expected known_string to be a string, %s given", getDataTypeString(known.getType()).c_str() ); return false; } if (!user.isString()) { raise_warning( "hash_equals(): Expected user_string to be a string, %s given", getDataTypeString(user.getType()).c_str() ); return false; } String known_str = known.toString(); String user_str = user.toString(); const auto known_len = known_str.size(); const auto known_limit = known_len - 1; const auto user_len = user_str.size(); int64_t result = known_len ^ user_len; int64_t ki = 0; for (int64_t ui = 0; ui < user_len; ++ui) { result |= user_str[ui] ^ known_str[ki]; if (ki < known_limit) { ++ki; } } return (result == 0); }
0
486,868
ffi_closure_alloc (size_t size, void **code) { void *ptr; if (!code) return NULL; ptr = dlmalloc (size); if (ptr) { msegmentptr seg = segment_holding (gm, ptr); *code = add_segment_exec_offset (ptr, seg); } return ptr; }
0
349,581
spa_base64_to_bits (char *out, int outlength, const char *in) /* base 64 to raw bytes in quasi-big-endian order, returning count of bytes */ { int len = 0; register uschar digit1, digit2, digit3, digit4; if (in[0] == '+' && in[1] == ' ') in += 2; if (*in == '\r') return (0); do { if (len >= outlength) /* Added by PH */ return (-1); /* Added by PH */ digit1 = in[0]; if (DECODE64 (digit1) == BAD) return (-1); digit2 = in[1]; if (DECODE64 (digit2) == BAD) return (-1); digit3 = in[2]; if (digit3 != '=' && DECODE64 (digit3) == BAD) return (-1); digit4 = in[3]; if (digit4 != '=' && DECODE64 (digit4) == BAD) return (-1); in += 4; *out++ = (DECODE64 (digit1) << 2) | (DECODE64 (digit2) >> 4); ++len; if (digit3 != '=') { if (len >= outlength) /* Added by PH */ return (-1); /* Added by PH */ *out++ = ((DECODE64 (digit2) << 4) & 0xf0) | (DECODE64 (digit3) >> 2); ++len; if (digit4 != '=') { if (len >= outlength) /* Added by PH */ return (-1); /* Added by PH */ *out++ = ((DECODE64 (digit3) << 6) & 0xc0) | DECODE64 (digit4); ++len; } } } while (*in && *in != '\r' && digit4 != '='); return (len); }
1
145,938
int FLTIsTemporalFilterType(const char *pszValue) { if (pszValue) { if ( strcasecmp(pszValue, "During") == 0 ) return MS_TRUE; } return MS_FALSE; }
0
441,380
int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op) { *new_op = op; ldout(s->cct, 10) << __func__ << " Starting retarget" << dendl; if (!(s->prot_flags & RGW_REST_WEBSITE)) return 0; int ret = store->get_bucket_info(*s->sysobj_ctx, s->bucket_tenant, s->bucket_name, s->bucket_info, NULL, &s->bucket_attrs); if (ret < 0) { // TODO-FUTURE: if the bucket does not exist, maybe expose it here? return -ERR_NO_SUCH_BUCKET; } if (!s->bucket_info.has_website) { // TODO-FUTURE: if the bucket has no WebsiteConfig, expose it here return -ERR_NO_SUCH_WEBSITE_CONFIGURATION; } rgw_obj_key new_obj; bool get_res = s->bucket_info.website_conf.get_effective_key(s->object.name, &new_obj.name, web_dir()); if (!get_res) { s->err.message = "The IndexDocument Suffix is not configurated or not well formed!"; ldout(s->cct, 5) << s->err.message << dendl; return -EINVAL; } ldout(s->cct, 10) << "retarget get_effective_key " << s->object << " -> " << new_obj << dendl; RGWBWRoutingRule rrule; bool should_redirect = s->bucket_info.website_conf.should_redirect(new_obj.name, 0, &rrule); if (should_redirect) { const string& hostname = s->info.env->get("HTTP_HOST", ""); const string& protocol = (s->info.env->get("SERVER_PORT_SECURE") ? "https" : "http"); int redirect_code = 0; rrule.apply_rule(protocol, hostname, s->object.name, &s->redirect, &redirect_code); // APply a custom HTTP response code if (redirect_code > 0) s->err.http_ret = redirect_code; // Apply a custom HTTP response code ldout(s->cct, 10) << "retarget redirect code=" << redirect_code << " proto+host:" << protocol << "://" << hostname << " -> " << s->redirect << dendl; return -ERR_WEBSITE_REDIRECT; } /* * FIXME: if s->object != new_obj, drop op and create a new op to handle * operation. Or remove this comment if it's not applicable anymore */ s->object = new_obj; return 0; }
0
190,062
size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs, const void* dict, size_t dictSize, const ZSTD_CDict* cdict, ZSTD_CCtx_params params, unsigned long long pledgedSrcSize) { DEBUGLOG(4, "ZSTD_initCStream_internal"); params.cParams = ZSTD_getCParamsFromCCtxParams(&params, pledgedSrcSize, dictSize); assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams))); assert(!((dict) && (cdict))); /* either dict or cdict, not both */ if (dict && dictSize >= 8) { DEBUGLOG(4, "loading dictionary of size %u", (U32)dictSize); if (zcs->staticSize) { /* static CCtx : never uses malloc */ /* incompatible with internal cdict creation */ return ERROR(memory_allocation); } ZSTD_freeCDict(zcs->cdictLocal); zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto, params.cParams, zcs->customMem); zcs->cdict = zcs->cdictLocal; if (zcs->cdictLocal == NULL) return ERROR(memory_allocation); } else { if (cdict) { params.cParams = ZSTD_getCParamsFromCDict(cdict); /* cParams are enforced from cdict; it includes windowLog */ } ZSTD_freeCDict(zcs->cdictLocal); zcs->cdictLocal = NULL; zcs->cdict = cdict; } return ZSTD_resetCStream_internal(zcs, NULL, 0, ZSTD_dct_auto, zcs->cdict, params, pledgedSrcSize); }
0
337,437
static void spitz_i2c_setup(PXA2xxState *cpu) { /* Attach the CPU on one end of our I2C bus. */ I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]); DeviceState *wm; /* Attach a WM8750 to the bus */ wm = i2c_create_slave(bus, "wm8750", 0); spitz_wm8750_addr(wm, 0, 0); qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM, qemu_allocate_irqs(spitz_wm8750_addr, wm, 1)[0]); /* .. and to the sound interface. */ cpu->i2s->opaque = wm; cpu->i2s->codec_out = wm8750_dac_dat; cpu->i2s->codec_in = wm8750_adc_dat; wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s); }
1
494,270
static int handle_ping_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc) { h2o_http2_ping_payload_t payload; int ret; if ((ret = h2o_http2_decode_ping_payload(&payload, frame, err_desc)) != 0) return ret; h2o_http2_encode_ping_frame(&conn->_write.buf, 1, payload.data); h2o_http2_conn_request_write(conn); return 0; }
0
156,154
void visit(Sequence &ope) override { for (auto op : ope.opes_) { op->accept(*this); } }
0
304,310
SYSCALL_DEFINE4(epoll_wait, int, epfd, struct epoll_event __user *, events, int, maxevents, int, timeout) { int error; struct file *file; struct eventpoll *ep; /* The maximum number of event must be greater than zero */ if (maxevents <= 0 || maxevents > EP_MAX_EVENTS) return -EINVAL; /* Verify that the area passed by the user is writeable */ if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event))) { error = -EFAULT; goto error_return; } /* Get the "struct file *" for the eventpoll file */ error = -EBADF; file = fget(epfd); if (!file) goto error_return; /* * We have to check that the file structure underneath the fd * the user passed to us _is_ an eventpoll file. */ error = -EINVAL; if (!is_file_epoll(file)) goto error_fput; /* * At this point it is safe to assume that the "private_data" contains * our own data structure. */ ep = file->private_data; /* Time to fish for events ... */ error = ep_poll(ep, events, maxevents, timeout); error_fput: fput(file); error_return: return error; }
0
107,883
mii_set_media_pcs (struct net_device *dev) { __u16 bmcr; __u16 esr; __u16 anar; int phy_addr; struct netdev_private *np; np = netdev_priv(dev); phy_addr = np->phy_addr; /* Auto-Negotiation? */ if (np->an_enable) { /* Advertise capabilities */ esr = mii_read (dev, phy_addr, PCS_ESR); anar = mii_read (dev, phy_addr, MII_ADVERTISE) & ~PCS_ANAR_HALF_DUPLEX & ~PCS_ANAR_FULL_DUPLEX; if (esr & (MII_ESR_1000BT_HD | MII_ESR_1000BX_HD)) anar |= PCS_ANAR_HALF_DUPLEX; if (esr & (MII_ESR_1000BT_FD | MII_ESR_1000BX_FD)) anar |= PCS_ANAR_FULL_DUPLEX; anar |= PCS_ANAR_PAUSE | PCS_ANAR_ASYMMETRIC; mii_write (dev, phy_addr, MII_ADVERTISE, anar); /* Soft reset PHY */ mii_write (dev, phy_addr, MII_BMCR, BMCR_RESET); bmcr = BMCR_ANENABLE | BMCR_ANRESTART | BMCR_RESET; mii_write (dev, phy_addr, MII_BMCR, bmcr); mdelay(1); } else { /* Force speed setting */ /* PHY Reset */ bmcr = BMCR_RESET; mii_write (dev, phy_addr, MII_BMCR, bmcr); mdelay(10); if (np->full_duplex) { bmcr = BMCR_FULLDPLX; printk (KERN_INFO "Manual full duplex\n"); } else { bmcr = 0; printk (KERN_INFO "Manual half duplex\n"); } mii_write (dev, phy_addr, MII_BMCR, bmcr); mdelay(10); /* Advertise nothing */ mii_write (dev, phy_addr, MII_ADVERTISE, 0); } return 0; }
0
274,772
static void rom_reset(void *unused) { Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { if (rom->fw_file) { continue; } if (rom->data == NULL) { continue; } if (rom->mr) { void *host = memory_region_get_ram_ptr(rom->mr); memcpy(host, rom->data, rom->datasize); } else { address_space_write_rom(rom->as, rom->addr, MEMTXATTRS_UNSPECIFIED, rom->data, rom->datasize); } if (rom->isrom) { /* rom needs to be written only once */ g_free(rom->data); rom->data = NULL; } /* * The rom loader is really on the same level as firmware in the guest * shadowing a ROM into RAM. Such a shadowing mechanism needs to ensure * that the instruction cache for that new region is clear, so that the * CPU definitely fetches its instructions from the just written data. */ cpu_flush_icache_range(rom->addr, rom->datasize); } }
0
349,321
static inline u32 __flow_hash_from_keys(struct flow_keys *keys, u32 keyval) { u32 hash; __flow_hash_consistentify(keys); hash = __flow_hash_words(flow_keys_hash_start(keys), flow_keys_hash_length(keys), keyval); if (!hash) hash = 1; return hash; }
1
106,604
static int opficom(RAsm *a, ut8 *data, const Opcode *op) { int l = 0; switch (op->operands_count) { case 1: if ( op->operands[0].type & OT_MEMORY ) { if ( op->operands[0].type & OT_WORD ) { data[l++] = 0xde; data[l++] = 0x10 | op->operands[0].regs[0]; } else if ( op->operands[0].type & OT_DWORD ) { data[l++] = 0xda; data[l++] = 0x10 | op->operands[0].regs[0]; } else { return -1; } } else { return -1; } break; default: return -1; } return l; }
0
262,810
showoneopt ( vimoption_T *p, int opt_flags /* OPT_LOCAL or OPT_GLOBAL */ ) { char_u *varp; int save_silent = silent_mode; silent_mode = FALSE; info_message = TRUE; /* use mch_msg(), not mch_errmsg() */ varp = get_varp_scope(p, opt_flags); // for 'modified' we also need to check if 'ff' or 'fenc' changed. if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed ? !curbufIsChanged() : !*(int *)varp)) { MSG_PUTS("no"); } else if ((p->flags & P_BOOL) && *(int *)varp < 0) { MSG_PUTS("--"); } else { MSG_PUTS(" "); } MSG_PUTS(p->fullname); if (!(p->flags & P_BOOL)) { msg_putchar('='); /* put value string in NameBuff */ option_value2string(p, opt_flags); msg_outtrans(NameBuff); } silent_mode = save_silent; info_message = FALSE; }
0
170,430
void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings, gfx::NativeView parent_view, int expected_page_count, bool has_selection, bool use_overlays, CancelableTask* callback) { DCHECK_EQ(ui_message_loop_, MessageLoop::current()); DCHECK(!is_print_dialog_box_shown_); DCHECK(!callback_.get()); DCHECK(worker_.get()); if (!worker_.get()) return; if (!worker_->message_loop()) { if (!worker_->Start()) { if (callback) { callback->Cancel(); delete callback; } NOTREACHED(); return; } } callback_.reset(callback); is_print_dialog_box_shown_ = ask_user_for_settings == ASK_USER; worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( worker_.get(), &PrintJobWorker::GetSettings, is_print_dialog_box_shown_, parent_view, expected_page_count, has_selection, use_overlays)); }
0
388,276
static int btrfs_ioctl_get_supported_features(struct file *file, void __user *arg) { static struct btrfs_ioctl_feature_flags features[3] = { INIT_FEATURE_FLAGS(SUPP), INIT_FEATURE_FLAGS(SAFE_SET), INIT_FEATURE_FLAGS(SAFE_CLEAR) }; if (copy_to_user(arg, &features, sizeof(features))) return -EFAULT; return 0; }
0
480,471
Mat_WriteEmptyVariable5(mat_t *mat, const char *name, int rank, size_t *dims) { mat_uint32_t array_flags; mat_uint32_t array_name_type = MAT_T_INT8; const mat_uint32_t matrix_type = MAT_T_MATRIX; int array_flags_type = MAT_T_UINT32, dims_array_type = MAT_T_INT32; int array_flags_size = 8, nBytes, i; const mat_uint32_t pad4 = 0; const mat_uint8_t pad1 = 0; size_t byteswritten = 0; long start = 0, end = 0; fwrite(&matrix_type, 4, 1, (FILE *)mat->fp); fwrite(&pad4, 4, 1, (FILE *)mat->fp); start = ftell((FILE *)mat->fp); /* Array Flags */ array_flags = MAT_C_DOUBLE; if ( mat->byteswap ) array_flags = Mat_int32Swap((mat_int32_t *)&array_flags); byteswritten += fwrite(&array_flags_type, 4, 1, (FILE *)mat->fp); byteswritten += fwrite(&array_flags_size, 4, 1, (FILE *)mat->fp); byteswritten += fwrite(&array_flags, 4, 1, (FILE *)mat->fp); byteswritten += fwrite(&pad4, 4, 1, (FILE *)mat->fp); /* Rank and Dimension */ nBytes = rank * 4; byteswritten += fwrite(&dims_array_type, 4, 1, (FILE *)mat->fp); byteswritten += fwrite(&nBytes, 4, 1, (FILE *)mat->fp); for ( i = 0; i < rank; i++ ) { mat_int32_t dim; dim = dims[i]; byteswritten += fwrite(&dim, 4, 1, (FILE *)mat->fp); } if ( rank % 2 != 0 ) byteswritten += fwrite(&pad4, 4, 1, (FILE *)mat->fp); if ( NULL == name ) { /* Name of variable */ byteswritten += fwrite(&array_name_type, 4, 1, (FILE *)mat->fp); byteswritten += fwrite(&pad4, 4, 1, (FILE *)mat->fp); } else { mat_int32_t array_name_len = (mat_int32_t)strlen(name); /* Name of variable */ if ( array_name_len <= 4 ) { array_name_type |= array_name_len << 16; byteswritten += fwrite(&array_name_type, 4, 1, (FILE *)mat->fp); byteswritten += fwrite(name, 1, array_name_len, (FILE *)mat->fp); for ( i = array_name_len; i < 4; i++ ) byteswritten += fwrite(&pad1, 1, 1, (FILE *)mat->fp); } else { byteswritten += fwrite(&array_name_type, 4, 1, (FILE *)mat->fp); byteswritten += fwrite(&array_name_len, 4, 1, (FILE *)mat->fp); byteswritten += fwrite(name, 1, array_name_len, (FILE *)mat->fp); if ( array_name_len % 8 ) for ( i = array_name_len % 8; i < 8; i++ ) byteswritten += fwrite(&pad1, 1, 1, (FILE *)mat->fp); } } nBytes = WriteData(mat, NULL, 0, MAT_T_DOUBLE); byteswritten += nBytes; if ( nBytes % 8 ) for ( i = nBytes % 8; i < 8; i++ ) byteswritten += fwrite(&pad1, 1, 1, (FILE *)mat->fp); end = ftell((FILE *)mat->fp); if ( start != -1L && end != -1L ) { nBytes = (int)(end - start); (void)fseek((FILE *)mat->fp, (long)-(nBytes + 4), SEEK_CUR); fwrite(&nBytes, 4, 1, (FILE *)mat->fp); (void)fseek((FILE *)mat->fp, end, SEEK_SET); } else { Mat_Critical("Couldn't determine file position"); } return byteswritten; }
0
504,623
static int __init acpi_parse_madt(unsigned long phys_addr, unsigned long size) { struct acpi_table_madt *madt = NULL; if (!phys_addr || !size || !cpu_has_apic) return -EINVAL; madt = (struct acpi_table_madt *)__acpi_map_table(phys_addr, size); if (!madt) { printk(KERN_WARNING PREFIX "Unable to map MADT\n"); return -ENODEV; } if (madt->lapic_address) { acpi_lapic_addr = (u64) madt->lapic_address; printk(KERN_DEBUG PREFIX "Local APIC address 0x%08x\n", madt->lapic_address); } acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id); return 0; }
0
89,751
static inline u32 nfsd4_getfh_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) { return (op_encode_hdr_size + 1) * sizeof(__be32) + NFS4_FHSIZE; }
0
388,006
set_display_device (GdmSession *self, const char *name) { g_debug ("GdmSession: Setting display device: %s", name); g_free (self->priv->display_device); self->priv->display_device = g_strdup (name); }
0
410,022
static inline int skb_inner_transport_offset(const struct sk_buff *skb) { return skb_inner_transport_header(skb) - skb->data;
0
244,970
virtual ~DisablePluginHelper() {}
0
360,098
get_pixbuf_for_content (goffset file_len, char *file_contents) { gboolean res; GdkPixbuf *pixbuf, *pixbuf2; GdkPixbufLoader *loader; gsize chunk_len; pixbuf = NULL; loader = gdk_pixbuf_loader_new (); g_signal_connect (loader, "size-prepared", G_CALLBACK (thumbnail_loader_size_prepared), NULL); /* For some reason we have to write in chunks, or gdk-pixbuf fails */ res = TRUE; while (res && file_len > 0) { chunk_len = file_len; res = gdk_pixbuf_loader_write (loader, file_contents, chunk_len, NULL); file_contents += chunk_len; file_len -= chunk_len; } if (res) { res = gdk_pixbuf_loader_close (loader, NULL); } if (res) { pixbuf = g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader)); } g_object_unref (G_OBJECT (loader)); if (pixbuf) { pixbuf2 = gdk_pixbuf_apply_embedded_orientation (pixbuf); g_object_unref (pixbuf); pixbuf = pixbuf2; } return pixbuf; }
0
352,413
void clear() { req = crow::request(); header_field.clear(); header_value.clear(); header_building_state = 0; qs_point = 0; }
1
384,071
idna_to_ascii_4z (const uint32_t * input, char **output, int flags) { const uint32_t *start = input; const uint32_t *end; char buf[64]; char *out = NULL; int rc; /* 1) Whenever dots are used as label separators, the following characters MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61 (halfwidth ideographic full stop). */ if (input[0] == 0) { /* Handle implicit zero-length root label. */ *output = malloc (1); if (!*output) return IDNA_MALLOC_ERROR; strcpy (*output, ""); return IDNA_SUCCESS; } if (DOTP (input[0]) && input[1] == 0) { /* Handle explicit zero-length root label. */ *output = malloc (2); if (!*output) return IDNA_MALLOC_ERROR; strcpy (*output, "."); return IDNA_SUCCESS; } *output = NULL; do { end = start; for (; *end && !DOTP (*end); end++) ; if (*end == '\0' && start == end) { /* Handle explicit zero-length root label. */ buf[0] = '\0'; } else { rc = idna_to_ascii_4i (start, (size_t) (end - start), buf, flags); if (rc != IDNA_SUCCESS) { free (out); return rc; } } if (out) { size_t l = strlen (out) + 1 + strlen (buf) + 1; char *newp = realloc (out, l); if (!newp) { free (out); return IDNA_MALLOC_ERROR; } out = newp; strcat (out, "."); strcat (out, buf); } else { out = strdup (buf); if (!out) return IDNA_MALLOC_ERROR; } start = end + 1; } while (*end); *output = out; return IDNA_SUCCESS; }
0
122,330
static struct NntpData *nntp_data_find(struct NntpServer *nserv, const char *group) { struct NntpData *nntp_data = mutt_hash_find(nserv->groups_hash, group); if (nntp_data) return nntp_data; size_t len = strlen(group) + 1; /* create NntpData structure and add it to hash */ nntp_data = mutt_mem_calloc(1, sizeof(struct NntpData) + len); nntp_data->group = (char *) nntp_data + sizeof(struct NntpData); mutt_str_strfcpy(nntp_data->group, group, len); nntp_data->nserv = nserv; nntp_data->deleted = true; mutt_hash_insert(nserv->groups_hash, nntp_data->group, nntp_data); /* add NntpData to list */ if (nserv->groups_num >= nserv->groups_max) { nserv->groups_max *= 2; mutt_mem_realloc(&nserv->groups_list, nserv->groups_max * sizeof(nntp_data)); } nserv->groups_list[nserv->groups_num++] = nntp_data; return nntp_data; }
0
483,763
static inline void hugetlb_unregister_node(struct node *node) {}
0
296,686
repodata_lookup_num(Repodata *data, Id solvid, Id keyname, unsigned long long notfound) { unsigned char *dp; Repokey *key; unsigned int high, low; dp = find_key_data(data, solvid, keyname, &key); if (!dp) return notfound; switch (key->type) { case REPOKEY_TYPE_NUM: data_read_num64(dp, &low, &high); return (unsigned long long)high << 32 | low; case REPOKEY_TYPE_CONSTANT: return key->size; default: return notfound; } }
0
330,526
static void stop_tco(const TestData *d) { uint32_t val; val = qpci_io_readw(d->dev, d->tco_io_base + TCO1_CNT); val |= TCO_TMR_HLT; qpci_io_writew(d->dev, d->tco_io_base + TCO1_CNT, val); }
1
101,804
static inline void syn_flood_warning(struct sk_buff *skb) { #ifdef CONFIG_SYN_COOKIES if (sysctl_tcp_syncookies) printk(KERN_INFO "TCPv6: Possible SYN flooding on port %d. " "Sending cookies.\n", ntohs(tcp_hdr(skb)->dest)); else #endif printk(KERN_INFO "TCPv6: Possible SYN flooding on port %d. " "Dropping request.\n", ntohs(tcp_hdr(skb)->dest)); }
0
59,592
static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical) { atomic_inc(&bbio->error); if (atomic_dec_and_test(&bbio->stripes_pending)) { /* Should be the original bio. */ WARN_ON(bio != bbio->orig_bio); btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; bio->bi_iter.bi_sector = logical >> 9; if (atomic_read(&bbio->error) > bbio->max_errors) bio->bi_status = BLK_STS_IOERR; else bio->bi_status = BLK_STS_OK; btrfs_end_bbio(bbio, bio); } }
0
429,419
void PngChunk::decodeIHDRChunk(const DataBuf& data, PngImageHeader& h) { enforce(data.size_ == 13, kerCorruptedMetadata); h.width = getLong((const byte*)data.pData_, bigEndian); h.height = getLong((const byte*)data.pData_ + 4, bigEndian); h.bitDepth = data.pData_[8]; h.colorType = data.pData_[9]; h.compressionMethod = data.pData_[10]; h.filterMethod = data.pData_[11]; h.interlaceMethod = data.pData_[12]; enforce(h.colorType == 0 || h.colorType == 2 || h.colorType == 3 || h.colorType == 4 || h.colorType == 6, kerCorruptedMetadata); switch(h.colorType) { case 0: enforce(h.bitDepth == 1 || h.bitDepth == 2 || h.bitDepth == 4 || h.bitDepth == 8 || h.bitDepth == 16, kerCorruptedMetadata); break; case 2: enforce(h.bitDepth == 8 || h.bitDepth == 16, kerCorruptedMetadata); break; case 3: enforce(h.bitDepth == 1 || h.bitDepth == 2 || h.bitDepth == 4 || h.bitDepth == 8, kerCorruptedMetadata); break; case 4: enforce(h.bitDepth == 8 || h.bitDepth == 16, kerCorruptedMetadata); break; case 6: enforce(h.bitDepth == 8 || h.bitDepth == 16, kerCorruptedMetadata); break; } enforce(h.compressionMethod == 0, kerCorruptedMetadata); enforce(h.filterMethod == 0, kerCorruptedMetadata); enforce(h.interlaceMethod == 0 || h.interlaceMethod == 1, kerCorruptedMetadata); }
0
341,245
static void vfio_pci_size_rom(VFIOPCIDevice *vdev) { uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset = vdev->config_offset + PCI_ROM_ADDRESS; DeviceState *dev = DEVICE(vdev); char name[32]; int fd = vdev->vbasedev.fd; if (vdev->pdev.romfile || !vdev->pdev.rom_bar) { /* Since pci handles romfile, just print a message and return */ if (vfio_blacklist_opt_rom(vdev) && vdev->pdev.romfile) { error_printf("Warning : Device at %04x:%02x:%02x.%x " "is known to cause system instability issues during " "option rom execution. " "Proceeding anyway since user specified romfile\n", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); } return; } /* * Use the same size ROM BAR as the physical device. The contents * will get filled in later when the guest tries to read it. */ if (pread(fd, &orig, 4, offset) != 4 || pwrite(fd, &size, 4, offset) != 4 || pread(fd, &size, 4, offset) != 4 || pwrite(fd, &orig, 4, offset) != 4) { error_report("%s(%04x:%02x:%02x.%x) failed: %m", __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); return; } size = ~(le32_to_cpu(size) & PCI_ROM_ADDRESS_MASK) + 1; if (!size) { return; } if (vfio_blacklist_opt_rom(vdev)) { if (dev->opts && qemu_opt_get(dev->opts, "rombar")) { error_printf("Warning : Device at %04x:%02x:%02x.%x " "is known to cause system instability issues during " "option rom execution. " "Proceeding anyway since user specified non zero value for " "rombar\n", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); } else { error_printf("Warning : Rom loading for device at " "%04x:%02x:%02x.%x has been disabled due to " "system instability issues. " "Specify rombar=1 or romfile to force\n", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); return; } } trace_vfio_pci_size_rom(vdev->vbasedev.name, size); snprintf(name, sizeof(name), "vfio[%04x:%02x:%02x.%x].rom", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); memory_region_init_io(&vdev->pdev.rom, OBJECT(vdev), &vfio_rom_ops, vdev, name, size); pci_register_bar(&vdev->pdev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_SPACE_MEMORY, &vdev->pdev.rom); vdev->pdev.has_rom = true; vdev->rom_read_failed = false; }
0
420,636
parse_strict_transport_security (const char *header, time_t *max_age, bool *include_subdomains) { param_token name, value; const char *c_max_age = NULL; bool is = false; /* includeSubDomains */ bool is_url_encoded = false; bool success = false; if (header) { /* Process the STS header. Keys should be matched case-insensitively. */ for (; extract_param (&header, &name, &value, ';', &is_url_encoded); is_url_encoded = false) { if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, "max-age")) { xfree(c_max_age); c_max_age = strdupdelim (value.b, value.e); } else if (BOUNDED_EQUAL_NO_CASE (name.b, name.e, "includeSubDomains")) is = true; } /* pass the parsed values over */ if (c_max_age) { /* If the string value goes out of a long's bounds, strtol() will return LONG_MIN or LONG_MAX. * In theory, the HSTS engine should be able to handle it. * Also, time_t is normally defined as a long, so this should not break. */ if (max_age) *max_age = (time_t) strtol (c_max_age, NULL, 10); if (include_subdomains) *include_subdomains = is; DEBUGP (("Parsed Strict-Transport-Security max-age = %s, includeSubDomains = %s\n", c_max_age, (is ? "true" : "false"))); xfree (c_max_age); success = true; } else { /* something weird happened */ logprintf (LOG_VERBOSE, "Could not parse String-Transport-Security header\n"); success = false; } } return success; }
0
342,223
static const uint8_t *decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){ int i, si, di; uint8_t *dst; int bufidx; // src[0]&0x80; //forbidden bit h->nal_ref_idc= src[0]>>5; h->nal_unit_type= src[0]&0x1F; src++; length--; #if 0 for(i=0; i<length; i++) printf("%2X ", src[i]); #endif for(i=0; i+1<length; i+=2){ if(src[i]) continue; if(i>0 && src[i-1]==0) i--; if(i+2<length && src[i+1]==0 && src[i+2]<=3){ if(src[i+2]!=3){ /* startcode, so we must be past the end */ length=i; } break; } } if(i>=length-1){ //no escaped 0 *dst_length= length; *consumed= length+1; //+1 for the header return src; } bufidx = h->nal_unit_type == NAL_DPC ? 1 : 0; // use second escape buffer for inter data h->rbsp_buffer[bufidx]= av_fast_realloc(h->rbsp_buffer[bufidx], &h->rbsp_buffer_size[bufidx], length); dst= h->rbsp_buffer[bufidx]; if (dst == NULL){ return NULL; } //printf("decoding esc\n"); si=di=0; while(si<length){ //remove escapes (very rare 1:2^22) if(si+2<length && src[si]==0 && src[si+1]==0 && src[si+2]<=3){ if(src[si+2]==3){ //escape dst[di++]= 0; dst[di++]= 0; si+=3; continue; }else //next start code break; } dst[di++]= src[si++]; } *dst_length= di; *consumed= si + 1;//+1 for the header //FIXME store exact number of bits in the getbitcontext (it is needed for decoding) return dst; }
1
317,131
static struct page *new_node_page(struct page *page, unsigned long node, int **x) { return alloc_pages_exact_node(node, GFP_HIGHUSER_MOVABLE, 0); }
0
462,877
TEST(BitTestMatchExpression, DoesNotMatchBinary2) { BSONArray bas = BSON_ARRAY(21 << 22 << 23 << 24 << 25); BSONArray bac = BSON_ARRAY(20 << 23 << 21); std::vector<uint32_t> bitPositionsSet = bsonArrayToBitPositions(bas); std::vector<uint32_t> bitPositionsClear = bsonArrayToBitPositions(bac); BSONObj match1 = fromjson("{a: {$binary: 'AANgAAAAAAAAAAAAAAAAAAAAAAAA', $type: '00'}}"); // Base64 to Binary: 00000000 00000011 01100000 BSONObj match2 = fromjson("{a: {$binary: 'JANgqwetkqwklEWRbWERKKJREtbq', $type: '00'}}"); // Base64 to Binary: ........ 00000011 01100000 BitsAllSetMatchExpression balls; BitsAllClearMatchExpression ballc; BitsAnySetMatchExpression banys; BitsAnyClearMatchExpression banyc; ASSERT_OK(balls.init("a", bitPositionsSet)); ASSERT_OK(ballc.init("a", bitPositionsClear)); ASSERT_OK(banys.init("a", bitPositionsSet)); ASSERT_OK(banyc.init("a", bitPositionsClear)); ASSERT_EQ((size_t)5, balls.numBitPositions()); ASSERT_EQ((size_t)3, ballc.numBitPositions()); ASSERT_EQ((size_t)5, banys.numBitPositions()); ASSERT_EQ((size_t)3, banyc.numBitPositions()); ASSERT(!balls.matchesSingleElement(match1["a"])); ASSERT(!balls.matchesSingleElement(match2["a"])); ASSERT(!ballc.matchesSingleElement(match1["a"])); ASSERT(!ballc.matchesSingleElement(match2["a"])); ASSERT(banys.matchesSingleElement(match1["a"])); ASSERT(banys.matchesSingleElement(match2["a"])); ASSERT(banyc.matchesSingleElement(match1["a"])); ASSERT(banyc.matchesSingleElement(match2["a"])); }
0
290,214
IN_PROC_BROWSER_TEST_F ( ExtensionMessageBubbleViewBrowserTest , ExtensionBubbleAnchoredToAppMenuWithOtherAction ) { TestBubbleAnchoredToAppMenuWithOtherAction ( ) ; }
0
84,120
skip_stream(struct archive_read *a, size_t skip_bytes) { struct _7zip *zip = (struct _7zip *)a->format->data; const void *p; int64_t skipped_bytes; size_t bytes = skip_bytes; if (zip->folder_index == 0) { /* * Optimization for a list mode. * Avoid unncecessary decoding operations. */ zip->si.ci.folders[zip->entry->folderIndex].skipped_bytes += skip_bytes; return (skip_bytes); } while (bytes) { skipped_bytes = read_stream(a, &p, bytes, 0); if (skipped_bytes < 0) return (skipped_bytes); if (skipped_bytes == 0) { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Truncated 7-Zip file body"); return (ARCHIVE_FATAL); } bytes -= (size_t)skipped_bytes; if (zip->pack_stream_bytes_unconsumed) read_consume(a); } return (skip_bytes); }
0
12,028
int __glXDispSwap_CreateContext(__GLXclientState *cl, GLbyte *pc) { xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc; __GLX_DECLARE_SWAP_VARIABLES; __GLX_SWAP_SHORT(&req->length); __GLX_SWAP_INT(&req->context); __GLX_SWAP_INT(&req->visual); return __glXDisp_CreateContext(cl, pc); }
1
177,733
static int lua_ap_getdir(lua_State *L) { request_rec *r; apr_dir_t *thedir; apr_finfo_t file_info; apr_status_t status; const char *directory; luaL_checktype(L, 1, LUA_TUSERDATA); luaL_checktype(L, 2, LUA_TSTRING); r = ap_lua_check_request_rec(L, 1); directory = lua_tostring(L, 2); if (apr_dir_open(&thedir, directory, r->pool) == APR_SUCCESS) { int i = 0; lua_newtable(L); do { status = apr_dir_read(&file_info, APR_FINFO_NAME, thedir); if (APR_STATUS_IS_INCOMPLETE(status)) { continue; /* ignore un-stat()able files */ } else if (status != APR_SUCCESS) { break; } lua_pushinteger(L, ++i); lua_pushstring(L, file_info.name); lua_settable(L, -3); } while (1); apr_dir_close(thedir); return 1; } else { return 0; } }
0
96,294
void nl80211_send_beacon_hint_event(struct wiphy *wiphy, struct ieee80211_channel *channel_before, struct ieee80211_channel *channel_after) { struct sk_buff *msg; void *hdr; struct nlattr *nl_freq; msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); if (!msg) return; hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_REG_BEACON_HINT); if (!hdr) { nlmsg_free(msg); return; } /* * Since we are applying the beacon hint to a wiphy we know its * wiphy_idx is valid */ if (nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy))) goto nla_put_failure; /* Before */ nl_freq = nla_nest_start_noflag(msg, NL80211_ATTR_FREQ_BEFORE); if (!nl_freq) goto nla_put_failure; if (nl80211_msg_put_channel(msg, wiphy, channel_before, false)) goto nla_put_failure; nla_nest_end(msg, nl_freq); /* After */ nl_freq = nla_nest_start_noflag(msg, NL80211_ATTR_FREQ_AFTER); if (!nl_freq) goto nla_put_failure; if (nl80211_msg_put_channel(msg, wiphy, channel_after, false)) goto nla_put_failure; nla_nest_end(msg, nl_freq); genlmsg_end(msg, hdr); rcu_read_lock(); genlmsg_multicast_allns(&nl80211_fam, msg, 0, NL80211_MCGRP_REGULATORY, GFP_ATOMIC); rcu_read_unlock(); return; nla_put_failure: nlmsg_free(msg); }
0
137,847
static int mem_cgroup_oom_control_write(struct cgroup *cgrp, struct cftype *cft, u64 val) { struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); struct mem_cgroup *parent; /* cannot set to root cgroup and only 0 and 1 are allowed */ if (!cgrp->parent || !((val == 0) || (val == 1))) return -EINVAL; parent = mem_cgroup_from_cont(cgrp->parent); cgroup_lock(); /* oom-kill-disable is a flag for subhierarchy. */ if ((parent->use_hierarchy) || (memcg->use_hierarchy && !list_empty(&cgrp->children))) { cgroup_unlock(); return -EINVAL; } memcg->oom_kill_disable = val; if (!val) memcg_oom_recover(memcg); cgroup_unlock(); return 0; }
0