unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
155,065 | 0 | SendTabToSelfModel* GetModel(const JavaParamRef<jobject>& j_profile) {
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
SendTabToSelfModel* model = SendTabToSelfSyncServiceFactory::GetInstance()
->GetForProfile(profile)
->GetSendTabToSelfModel();
LogModelLoadedInTime(model->IsReady());
return model;
}
| 13,500 |
35,891 | 0 | static sctp_ierror_t sctp_process_unk_param(const struct sctp_association *asoc,
union sctp_params param,
struct sctp_chunk *chunk,
struct sctp_chunk **errp)
{
int retval = SCTP_IERROR_NO_ERROR;
switch (param.p->type & SCTP_PARAM_ACTION_MASK) {
case SCTP_PARAM_ACTION_DISCARD:
retval = SCTP_IERROR_ERROR;
break;
case SCTP_PARAM_ACTION_SKIP:
break;
case SCTP_PARAM_ACTION_DISCARD_ERR:
retval = SCTP_IERROR_ERROR;
/* Fall through */
case SCTP_PARAM_ACTION_SKIP_ERR:
/* Make an ERROR chunk, preparing enough room for
* returning multiple unknown parameters.
*/
if (NULL == *errp)
*errp = sctp_make_op_error_fixed(asoc, chunk);
if (*errp) {
if (!sctp_init_cause_fixed(*errp, SCTP_ERROR_UNKNOWN_PARAM,
WORD_ROUND(ntohs(param.p->length))))
sctp_addto_chunk_fixed(*errp,
WORD_ROUND(ntohs(param.p->length)),
param.v);
} else {
/* If there is no memory for generating the ERROR
* report as specified, an ABORT will be triggered
* to the peer and the association won't be
* established.
*/
retval = SCTP_IERROR_NOMEM;
}
break;
default:
break;
}
return retval;
}
| 13,501 |
35,022 | 0 | static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
char __user *optval,
int __user *optlen)
{
struct sctp_association *asoc;
struct list_head *pos;
int cnt = 0;
struct sctp_getaddrs_old getaddrs;
struct sctp_transport *from;
void __user *to;
union sctp_addr temp;
struct sctp_sock *sp = sctp_sk(sk);
int addrlen;
if (len != sizeof(struct sctp_getaddrs_old))
return -EINVAL;
if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs_old)))
return -EFAULT;
if (getaddrs.addr_num <= 0) return -EINVAL;
/* For UDP-style sockets, id specifies the association to query. */
asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
if (!asoc)
return -EINVAL;
to = (void __user *)getaddrs.addrs;
list_for_each(pos, &asoc->peer.transport_addr_list) {
from = list_entry(pos, struct sctp_transport, transports);
memcpy(&temp, &from->ipaddr, sizeof(temp));
sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
if (copy_to_user(to, &temp, addrlen))
return -EFAULT;
to += addrlen ;
cnt ++;
if (cnt >= getaddrs.addr_num) break;
}
getaddrs.addr_num = cnt;
if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs_old)))
return -EFAULT;
return 0;
}
| 13,502 |
16,919 | 0 | static int count_contiguous_clusters(uint64_t nb_clusters, int cluster_size,
uint64_t *l2_table, uint64_t stop_flags)
{
int i;
uint64_t mask = stop_flags | L2E_OFFSET_MASK | QCOW_OFLAG_COMPRESSED;
uint64_t first_entry = be64_to_cpu(l2_table[0]);
uint64_t offset = first_entry & mask;
if (!offset)
return 0;
assert(qcow2_get_cluster_type(first_entry) != QCOW2_CLUSTER_COMPRESSED);
for (i = 0; i < nb_clusters; i++) {
uint64_t l2_entry = be64_to_cpu(l2_table[i]) & mask;
if (offset + (uint64_t) i * cluster_size != l2_entry) {
break;
}
}
return i;
}
| 13,503 |
128,108 | 0 | void SynchronousCompositorOutputSurface::Reshape(
const gfx::Size& size, float scale_factor) {
}
| 13,504 |
3,429 | 0 | hook_process_child (struct t_hook *hook_process)
{
char *exec_args[4] = { "sh", "-c", NULL, NULL };
/*
* close stdin, so that process will fail to read stdin (process reading
* stdin should not be run inside WeeChat!)
*/
close (STDIN_FILENO);
/* redirect stdout/stderr to pipe (so that father process can read them) */
close (HOOK_PROCESS(hook_process, child_read[HOOK_PROCESS_STDOUT]));
close (HOOK_PROCESS(hook_process, child_read[HOOK_PROCESS_STDERR]));
if (dup2 (HOOK_PROCESS(hook_process, child_write[HOOK_PROCESS_STDOUT]),
STDOUT_FILENO) < 0)
{
_exit (EXIT_FAILURE);
}
if (dup2 (HOOK_PROCESS(hook_process, child_write[HOOK_PROCESS_STDERR]),
STDERR_FILENO) < 0)
{
_exit (EXIT_FAILURE);
}
/* launch command */
exec_args[2] = HOOK_PROCESS(hook_process, command);
execvp (exec_args[0], exec_args);
/* should not be executed if execvp was ok */
fprintf (stderr, "Error with command '%s'\n",
HOOK_PROCESS(hook_process, command));
_exit (EXIT_FAILURE);
}
| 13,505 |
24,315 | 0 | static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
struct net_device *dev,
enum nl80211_iftype type)
{
struct ieee80211_sub_if_data *sdata;
u64 mask, start, addr, val, inc;
u8 *m;
u8 tmp_addr[ETH_ALEN];
int i;
/* default ... something at least */
memcpy(dev->perm_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
if (is_zero_ether_addr(local->hw.wiphy->addr_mask) &&
local->hw.wiphy->n_addresses <= 1)
return;
mutex_lock(&local->iflist_mtx);
switch (type) {
case NL80211_IFTYPE_MONITOR:
/* doesn't matter */
break;
case NL80211_IFTYPE_WDS:
case NL80211_IFTYPE_AP_VLAN:
/* match up with an AP interface */
list_for_each_entry(sdata, &local->interfaces, list) {
if (sdata->vif.type != NL80211_IFTYPE_AP)
continue;
memcpy(dev->perm_addr, sdata->vif.addr, ETH_ALEN);
break;
}
/* keep default if no AP interface present */
break;
default:
/* assign a new address if possible -- try n_addresses first */
for (i = 0; i < local->hw.wiphy->n_addresses; i++) {
bool used = false;
list_for_each_entry(sdata, &local->interfaces, list) {
if (memcmp(local->hw.wiphy->addresses[i].addr,
sdata->vif.addr, ETH_ALEN) == 0) {
used = true;
break;
}
}
if (!used) {
memcpy(dev->perm_addr,
local->hw.wiphy->addresses[i].addr,
ETH_ALEN);
break;
}
}
/* try mask if available */
if (is_zero_ether_addr(local->hw.wiphy->addr_mask))
break;
m = local->hw.wiphy->addr_mask;
mask = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) |
((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
if (__ffs64(mask) + hweight64(mask) != fls64(mask)) {
/* not a contiguous mask ... not handled now! */
printk(KERN_DEBUG "not contiguous\n");
break;
}
m = local->hw.wiphy->perm_addr;
start = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) |
((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
inc = 1ULL<<__ffs64(mask);
val = (start & mask);
addr = (start & ~mask) | (val & mask);
do {
bool used = false;
tmp_addr[5] = addr >> 0*8;
tmp_addr[4] = addr >> 1*8;
tmp_addr[3] = addr >> 2*8;
tmp_addr[2] = addr >> 3*8;
tmp_addr[1] = addr >> 4*8;
tmp_addr[0] = addr >> 5*8;
val += inc;
list_for_each_entry(sdata, &local->interfaces, list) {
if (memcmp(tmp_addr, sdata->vif.addr,
ETH_ALEN) == 0) {
used = true;
break;
}
}
if (!used) {
memcpy(dev->perm_addr, tmp_addr, ETH_ALEN);
break;
}
addr = (start & ~mask) | (val & mask);
} while (addr != start);
break;
}
mutex_unlock(&local->iflist_mtx);
}
| 13,506 |
105,847 | 0 | HRESULT UrlmonUrlRequest::StartAsyncDownload() {
DVLOG(1) << __FUNCTION__ << me() << url();
HRESULT hr = E_FAIL;
DCHECK((moniker_ && bind_context_) || (!moniker_ && !bind_context_));
if (!moniker_.get()) {
std::wstring wide_url = UTF8ToWide(url());
hr = CreateURLMonikerEx(NULL, wide_url.c_str(), moniker_.Receive(),
URL_MK_UNIFORM);
if (FAILED(hr)) {
NOTREACHED() << "CreateURLMonikerEx failed. Error: " << hr;
return hr;
}
}
if (bind_context_.get() == NULL) {
hr = ::CreateAsyncBindCtxEx(NULL, 0, this, NULL,
bind_context_.Receive(), 0);
DCHECK(SUCCEEDED(hr)) << "CreateAsyncBindCtxEx failed. Error: " << hr;
} else {
hr = ::RegisterBindStatusCallback(bind_context_, this, NULL, 0);
DCHECK(SUCCEEDED(hr)) << "RegisterBindStatusCallback failed. Error: " << hr;
}
if (SUCCEEDED(hr)) {
base::win::ScopedComPtr<IStream> stream;
base::win::ScopedComPtr<IHttpSecurity> self(this);
base::win::ScopedComPtr<BindContextInfo> info;
BindContextInfo::FromBindContext(bind_context_, info.Receive());
DCHECK(info);
if (info)
info->set_chrome_request(true);
hr = moniker_->BindToStorage(bind_context_, NULL, __uuidof(IStream),
reinterpret_cast<void**>(stream.Receive()));
if (hr == S_OK)
DCHECK(binding_ != NULL || status_.get_state() == Status::DONE);
if (FAILED(hr)) {
DLOG(ERROR) << __FUNCTION__ << me() <<
base::StringPrintf("IUrlMoniker::BindToStorage failed 0x%08X.", hr);
}
}
DLOG_IF(ERROR, FAILED(hr)) << me() <<
base::StringPrintf(L"StartAsyncDownload failed: 0x%08X", hr);
return hr;
}
| 13,507 |
104,984 | 0 | void GraphicsContext::setPlatformCompositeOperation(CompositeOperator op)
{
if (m_data->context)
{
#if wxCHECK_VERSION(2,9,0)
m_data->context->SetLogicalFunction(static_cast<wxRasterOperationMode>(getWxCompositingOperation(op, false)));
#else
m_data->context->SetLogicalFunction(getWxCompositingOperation(op, false));
#endif
}
}
| 13,508 |
86,522 | 0 | static int storebuffer(int output, FILE *data)
{
char **buffer = (char **)data;
unsigned char outc = (unsigned char)output;
**buffer = outc;
(*buffer)++;
return outc; /* act like fputc() ! */
}
| 13,509 |
153,217 | 0 | void DesktopWindowTreeHostX11::EnableEventListening() {
DCHECK_GT(modal_dialog_counter_, 0UL);
if (!--modal_dialog_counter_)
targeter_for_modal_.reset();
}
| 13,510 |
28,499 | 0 | void qeth_clear_thread_start_bit(struct qeth_card *card, unsigned long thread)
{
unsigned long flags;
spin_lock_irqsave(&card->thread_mask_lock, flags);
card->thread_start_mask &= ~thread;
spin_unlock_irqrestore(&card->thread_mask_lock, flags);
wake_up(&card->wait_q);
}
| 13,511 |
70,226 | 0 | LogL10toY(int p10) /* compute luminance from 10-bit LogL */
{
if (p10 == 0)
return (0.);
return (exp(M_LN2/64.*(p10+.5) - M_LN2*12.));
}
| 13,512 |
150,538 | 0 | uint64_t received_page_id() const { return received_page_id_; }
| 13,513 |
64,466 | 0 | static int cmp(RConfigNode *a, RConfigNode *b) {
return strcmp (a->name, b->name);
}
| 13,514 |
156,928 | 0 | void NavigationRequest::CommitErrorPage(
RenderFrameHostImpl* render_frame_host,
const base::Optional<std::string>& error_page_content) {
UpdateRequestNavigationParamsHistory();
frame_tree_node_->TransferNavigationRequestOwnership(render_frame_host);
navigation_handle_->ReadyToCommitNavigation(render_frame_host, true);
render_frame_host->FailedNavigation(common_params_, request_params_,
has_stale_copy_in_cache_, net_error_,
error_page_content);
}
| 13,515 |
107,086 | 0 | WebCore::IntSize QQuickWebViewPrivate::viewSize() const
{
return WebCore::IntSize(pageView->width(), pageView->height());
}
| 13,516 |
90,326 | 0 | void megasas_do_ocr(struct megasas_instance *instance)
{
if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS1064R) ||
(instance->pdev->device == PCI_DEVICE_ID_DELL_PERC5) ||
(instance->pdev->device == PCI_DEVICE_ID_LSI_VERDE_ZCR)) {
*instance->consumer = cpu_to_le32(MEGASAS_ADPRESET_INPROG_SIGN);
}
instance->instancet->disable_intr(instance);
atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_INFAULT);
instance->issuepend_done = 0;
atomic_set(&instance->fw_outstanding, 0);
megasas_internal_reset_defer_cmds(instance);
process_fw_state_change_wq(&instance->work_init);
}
| 13,517 |
188,165 | 1 | status_t OMXNodeInstance::useBuffer(
OMX_U32 portIndex, const sp<IMemory> ¶ms,
OMX::buffer_id *buffer, OMX_U32 allottedSize) {
if (params == NULL || buffer == NULL) {
ALOGE("b/25884056");
return BAD_VALUE;
}
Mutex::Autolock autoLock(mLock);
if (allottedSize > params->size()) {
return BAD_VALUE;
}
BufferMeta *buffer_meta = new BufferMeta(params, portIndex);
OMX_BUFFERHEADERTYPE *header;
OMX_ERRORTYPE err = OMX_UseBuffer(
mHandle, &header, portIndex, buffer_meta,
allottedSize, static_cast<OMX_U8 *>(params->pointer()));
if (err != OMX_ErrorNone) {
CLOG_ERROR(useBuffer, err, SIMPLE_BUFFER(
portIndex, (size_t)allottedSize, params->pointer()));
delete buffer_meta;
buffer_meta = NULL;
*buffer = 0;
return StatusFromOMXError(err);
}
CHECK_EQ(header->pAppPrivate, buffer_meta);
*buffer = makeBufferID(header);
addActiveBuffer(portIndex, *buffer);
sp<GraphicBufferSource> bufferSource(getGraphicBufferSource());
if (bufferSource != NULL && portIndex == kPortIndexInput) {
bufferSource->addCodecBuffer(header);
}
CLOG_BUFFER(useBuffer, NEW_BUFFER_FMT(
*buffer, portIndex, "%u(%zu)@%p", allottedSize, params->size(), params->pointer()));
return OK;
}
| 13,518 |
185,986 | 1 | static void JNI_WebApkUpdateManager_StoreWebApkUpdateRequestToFile(
JNIEnv* env,
const JavaParamRef<jstring>& java_update_request_path,
const JavaParamRef<jstring>& java_start_url,
const JavaParamRef<jstring>& java_scope,
const JavaParamRef<jstring>& java_name,
const JavaParamRef<jstring>& java_short_name,
const JavaParamRef<jstring>& java_primary_icon_url,
const JavaParamRef<jobject>& java_primary_icon_bitmap,
const JavaParamRef<jstring>& java_badge_icon_url,
const JavaParamRef<jobject>& java_badge_icon_bitmap,
const JavaParamRef<jobjectArray>& java_icon_urls,
const JavaParamRef<jobjectArray>& java_icon_hashes,
jint java_display_mode,
jint java_orientation,
jlong java_theme_color,
jlong java_background_color,
const JavaParamRef<jstring>& java_web_manifest_url,
const JavaParamRef<jstring>& java_webapk_package,
jint java_webapk_version,
jboolean java_is_manifest_stale,
jint java_update_reason,
const JavaParamRef<jobject>& java_callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
std::string update_request_path =
ConvertJavaStringToUTF8(env, java_update_request_path);
ShortcutInfo info(GURL(ConvertJavaStringToUTF8(env, java_start_url)));
info.scope = GURL(ConvertJavaStringToUTF8(env, java_scope));
info.name = ConvertJavaStringToUTF16(env, java_name);
info.short_name = ConvertJavaStringToUTF16(env, java_short_name);
info.user_title = info.short_name;
info.display = static_cast<blink::WebDisplayMode>(java_display_mode);
info.orientation =
static_cast<blink::WebScreenOrientationLockType>(java_orientation);
info.theme_color = (int64_t)java_theme_color;
info.background_color = (int64_t)java_background_color;
info.best_primary_icon_url =
GURL(ConvertJavaStringToUTF8(env, java_primary_icon_url));
info.best_badge_icon_url =
GURL(ConvertJavaStringToUTF8(env, java_badge_icon_url));
info.manifest_url = GURL(ConvertJavaStringToUTF8(env, java_web_manifest_url));
base::android::AppendJavaStringArrayToStringVector(env, java_icon_urls,
&info.icon_urls);
std::vector<std::string> icon_hashes;
base::android::AppendJavaStringArrayToStringVector(env, java_icon_hashes,
&icon_hashes);
std::map<std::string, std::string> icon_url_to_murmur2_hash;
for (size_t i = 0; i < info.icon_urls.size(); ++i)
icon_url_to_murmur2_hash[info.icon_urls[i]] = icon_hashes[i];
gfx::JavaBitmap java_primary_icon_bitmap_lock(java_primary_icon_bitmap);
SkBitmap primary_icon =
gfx::CreateSkBitmapFromJavaBitmap(java_primary_icon_bitmap_lock);
primary_icon.setImmutable();
SkBitmap badge_icon;
if (!java_badge_icon_bitmap.is_null()) {
gfx::JavaBitmap java_badge_icon_bitmap_lock(java_badge_icon_bitmap);
gfx::CreateSkBitmapFromJavaBitmap(java_badge_icon_bitmap_lock);
badge_icon.setImmutable();
}
std::string webapk_package;
ConvertJavaStringToUTF8(env, java_webapk_package, &webapk_package);
WebApkUpdateReason update_reason =
static_cast<WebApkUpdateReason>(java_update_reason);
WebApkInstaller::StoreUpdateRequestToFile(
base::FilePath(update_request_path), info, primary_icon, badge_icon,
webapk_package, std::to_string(java_webapk_version),
icon_url_to_murmur2_hash, java_is_manifest_stale, update_reason,
base::BindOnce(&base::android::RunBooleanCallbackAndroid,
ScopedJavaGlobalRef<jobject>(java_callback)));
}
| 13,519 |
154,387 | 0 | bool GLES2DecoderImpl::ValidateStencilStateForDraw(const char* function_name) {
if (!state_.stencil_state_changed_since_validation) {
return true;
}
GLenum stencil_format = GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER);
uint8_t stencil_bits = GLES2Util::StencilBitsPerPixel(stencil_format);
if (state_.enable_flags.stencil_test && stencil_bits > 0) {
DCHECK_LE(stencil_bits, 8U);
GLuint max_stencil_value = (1 << stencil_bits) - 1;
GLint max_stencil_ref = static_cast<GLint>(max_stencil_value);
bool different_refs =
base::ClampToRange(state_.stencil_front_ref, 0, max_stencil_ref) !=
base::ClampToRange(state_.stencil_back_ref, 0, max_stencil_ref);
bool different_writemasks =
(state_.stencil_front_writemask & max_stencil_value) !=
(state_.stencil_back_writemask & max_stencil_value);
bool different_value_masks =
(state_.stencil_front_mask & max_stencil_value) !=
(state_.stencil_back_mask & max_stencil_value);
if (different_refs || different_writemasks || different_value_masks) {
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
"Front/back stencil settings do not match.");
return false;
}
}
state_.stencil_state_changed_since_validation = false;
return true;
}
| 13,520 |
58,725 | 0 | static int check_tty_count(struct tty_struct *tty, const char *routine)
{
#ifdef CHECK_TTY_COUNT
struct list_head *p;
int count = 0;
spin_lock(&tty_files_lock);
list_for_each(p, &tty->tty_files) {
count++;
}
spin_unlock(&tty_files_lock);
if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
tty->driver->subtype == PTY_TYPE_SLAVE &&
tty->link && tty->link->count)
count++;
if (tty->count != count) {
printk(KERN_WARNING "Warning: dev (%s) tty->count(%d) "
"!= #fd's(%d) in %s\n",
tty->name, tty->count, count, routine);
return count;
}
#endif
return 0;
}
| 13,521 |
167,973 | 0 | void LocalFrame::SetAdTrackerForTesting(AdTracker* ad_tracker) {
ad_tracker_->Shutdown();
ad_tracker_ = ad_tracker;
}
| 13,522 |
83 | 0 | long ssl3_default_timeout(void)
{
/* 2 hours, the 24 hours mentioned in the SSLv3 spec
* is way too long for http, the cache would over fill */
return(60*60*2);
}
| 13,523 |
18,990 | 0 | static void *established_get_first(struct seq_file *seq)
{
struct tcp_iter_state *st = seq->private;
struct net *net = seq_file_net(seq);
void *rc = NULL;
st->offset = 0;
for (; st->bucket <= tcp_hashinfo.ehash_mask; ++st->bucket) {
struct sock *sk;
struct hlist_nulls_node *node;
struct inet_timewait_sock *tw;
spinlock_t *lock = inet_ehash_lockp(&tcp_hashinfo, st->bucket);
/* Lockless fast path for the common case of empty buckets */
if (empty_bucket(st))
continue;
spin_lock_bh(lock);
sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
if (sk->sk_family != st->family ||
!net_eq(sock_net(sk), net)) {
continue;
}
rc = sk;
goto out;
}
st->state = TCP_SEQ_STATE_TIME_WAIT;
inet_twsk_for_each(tw, node,
&tcp_hashinfo.ehash[st->bucket].twchain) {
if (tw->tw_family != st->family ||
!net_eq(twsk_net(tw), net)) {
continue;
}
rc = tw;
goto out;
}
spin_unlock_bh(lock);
st->state = TCP_SEQ_STATE_ESTABLISHED;
}
out:
return rc;
}
| 13,524 |
80,566 | 0 | GF_Box *traf_New()
{
ISOM_DECL_BOX_ALLOC(GF_TrackFragmentBox, GF_ISOM_BOX_TYPE_TRAF);
tmp->TrackRuns = gf_list_new();
return (GF_Box *)tmp;
}
| 13,525 |
17,968 | 0 | kex_send_newkeys(struct ssh *ssh)
{
int r;
kex_reset_dispatch(ssh);
if ((r = sshpkt_start(ssh, SSH2_MSG_NEWKEYS)) != 0 ||
(r = sshpkt_send(ssh)) != 0)
return r;
debug("SSH2_MSG_NEWKEYS sent");
debug("expecting SSH2_MSG_NEWKEYS");
ssh_dispatch_set(ssh, SSH2_MSG_NEWKEYS, &kex_input_newkeys);
if (ssh->kex->ext_info_c)
if ((r = kex_send_ext_info(ssh)) != 0)
return r;
return 0;
}
| 13,526 |
183,054 | 1 | cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount)
{
const cdf_section_header_t *shp;
cdf_section_header_t sh;
const uint8_t *p, *q, *e;
int16_t s16;
int32_t s32;
uint32_t u32;
int64_t s64;
uint64_t u64;
cdf_timestamp_t tp;
size_t i, o, o4, nelements, j;
cdf_property_info_t *inp;
if (offs > UINT32_MAX / 4) {
errno = EFTYPE;
goto out;
}
shp = CAST(const cdf_section_header_t *, (const void *)
((const char *)sst->sst_tab + offs));
if (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1)
goto out;
sh.sh_len = CDF_TOLE4(shp->sh_len);
#define CDF_SHLEN_LIMIT (UINT32_MAX / 8)
if (sh.sh_len > CDF_SHLEN_LIMIT) {
errno = EFTYPE;
goto out;
}
sh.sh_properties = CDF_TOLE4(shp->sh_properties);
#define CDF_PROP_LIMIT (UINT32_MAX / (4 * sizeof(*inp)))
if (sh.sh_properties > CDF_PROP_LIMIT)
goto out;
DPRINTF(("section len: %u properties %u\n", sh.sh_len,
sh.sh_properties));
if (*maxcount) {
if (*maxcount > CDF_PROP_LIMIT)
goto out;
*maxcount += sh.sh_properties;
inp = CAST(cdf_property_info_t *,
realloc(*info, *maxcount * sizeof(*inp)));
} else {
*maxcount = sh.sh_properties;
inp = CAST(cdf_property_info_t *,
malloc(*maxcount * sizeof(*inp)));
}
if (inp == NULL)
goto out;
*info = inp;
inp += *count;
*count += sh.sh_properties;
p = CAST(const uint8_t *, (const void *)
((const char *)(const void *)sst->sst_tab +
offs + sizeof(sh)));
e = CAST(const uint8_t *, (const void *)
(((const char *)(const void *)shp) + sh.sh_len));
if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
goto out;
for (i = 0; i < sh.sh_properties; i++) {
q = (const uint8_t *)(const void *)
((const char *)(const void *)p +
CDF_GETUINT32(p, (i << 1) + 1)) - 2 * sizeof(uint32_t);
if (q > e) {
DPRINTF(("Ran of the end %p > %p\n", q, e));
goto out;
}
inp[i].pi_id = CDF_GETUINT32(p, i << 1);
inp[i].pi_type = CDF_GETUINT32(q, 0);
DPRINTF(("%d) id=%x type=%x offs=%x,%d\n", i, inp[i].pi_id,
inp[i].pi_type, q - p, CDF_GETUINT32(p, (i << 1) + 1)));
if (inp[i].pi_type & CDF_VECTOR) {
nelements = CDF_GETUINT32(q, 1);
o = 2;
} else {
nelements = 1;
o = 1;
}
o4 = o * sizeof(uint32_t);
if (inp[i].pi_type & (CDF_ARRAY|CDF_BYREF|CDF_RESERVED))
goto unknown;
switch (inp[i].pi_type & CDF_TYPEMASK) {
case CDF_NULL:
case CDF_EMPTY:
break;
case CDF_SIGNED16:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&s16, &q[o4], sizeof(s16));
inp[i].pi_s16 = CDF_TOLE2(s16);
break;
case CDF_SIGNED32:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&s32, &q[o4], sizeof(s32));
inp[i].pi_s32 = CDF_TOLE4((uint32_t)s32);
break;
case CDF_BOOL:
case CDF_UNSIGNED32:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&u32, &q[o4], sizeof(u32));
inp[i].pi_u32 = CDF_TOLE4(u32);
break;
case CDF_SIGNED64:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&s64, &q[o4], sizeof(s64));
inp[i].pi_s64 = CDF_TOLE8((uint64_t)s64);
break;
case CDF_UNSIGNED64:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&u64, &q[o4], sizeof(u64));
inp[i].pi_u64 = CDF_TOLE8((uint64_t)u64);
break;
case CDF_LENGTH32_STRING:
case CDF_LENGTH32_WSTRING:
if (nelements > 1) {
size_t nelem = inp - *info;
if (*maxcount > CDF_PROP_LIMIT
|| nelements > CDF_PROP_LIMIT)
goto out;
*maxcount += nelements;
inp = CAST(cdf_property_info_t *,
realloc(*info, *maxcount * sizeof(*inp)));
if (inp == NULL)
goto out;
*info = inp;
inp = *info + nelem;
}
DPRINTF(("nelements = %d\n", nelements));
for (j = 0; j < nelements; j++, i++) {
uint32_t l = CDF_GETUINT32(q, o);
inp[i].pi_str.s_len = l;
inp[i].pi_str.s_buf = (const char *)
(const void *)(&q[o4 + sizeof(l)]);
DPRINTF(("l = %d, r = %d, s = %s\n", l,
CDF_ROUND(l, sizeof(l)),
inp[i].pi_str.s_buf));
l = 4 + (uint32_t)CDF_ROUND(l, sizeof(l));
o += l >> 2;
o4 = o * sizeof(uint32_t);
}
i--;
break;
case CDF_FILETIME:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
(void)memcpy(&tp, &q[o4], sizeof(tp));
inp[i].pi_tp = CDF_TOLE8((uint64_t)tp);
break;
case CDF_CLIPBOARD:
if (inp[i].pi_type & CDF_VECTOR)
goto unknown;
break;
default:
unknown:
DPRINTF(("Don't know how to deal with %x\n",
inp[i].pi_type));
goto out;
}
}
return 0;
out:
free(*info);
return -1;
}
| 13,527 |
153,234 | 0 | void DesktopWindowTreeHostX11::GetWindowPlacement(
gfx::Rect* bounds,
ui::WindowShowState* show_state) const {
*bounds = GetRestoredBounds();
if (IsFullscreen()) {
*show_state = ui::SHOW_STATE_FULLSCREEN;
} else if (IsMinimized()) {
*show_state = ui::SHOW_STATE_MINIMIZED;
} else if (IsMaximized()) {
*show_state = ui::SHOW_STATE_MAXIMIZED;
} else if (!IsActive()) {
*show_state = ui::SHOW_STATE_INACTIVE;
} else {
*show_state = ui::SHOW_STATE_NORMAL;
}
}
| 13,528 |
127,855 | 0 | static bool CheckAc3(const uint8* buffer, int buffer_size) {
RCHECK(buffer_size > 6);
int offset = 0;
while (offset + 6 < buffer_size) {
BitReader reader(buffer + offset, 6);
RCHECK(ReadBits(&reader, 16) == kAc3SyncWord);
reader.SkipBits(16);
int sample_rate_code = ReadBits(&reader, 2);
RCHECK(sample_rate_code != 3); // Reserved.
int frame_size_code = ReadBits(&reader, 6);
RCHECK(frame_size_code < 38); // Undefined.
RCHECK(ReadBits(&reader, 5) < 10); // Normally 8 or 6, 16 used by EAC3.
offset += kAc3FrameSizeTable[frame_size_code][sample_rate_code];
}
return true;
}
| 13,529 |
61,060 | 0 | f (const char *format,
...)
{
va_list va;
char *res;
va_start (va, format);
res = eel_strdup_vprintf_with_custom (handlers, format, va);
va_end (va);
return res;
}
| 13,530 |
64,138 | 0 | static int _server_handle_Hg(libgdbr_t *g, int (*cmd_cb) (void*, const char*, char*, size_t), void *core_ptr) {
char cmd[32];
int tid;
if (send_ack (g) < 0) {
return -1;
}
if (g->data_len <= 2 || isalpha (g->data[2])) {
return send_msg (g, "E01");
}
if (g->data[2] == '0' || !strncmp (g->data + 2, "-1", 2)) {
return send_msg (g, "OK");
}
sscanf (g->data + 2, "%x", &tid);
snprintf (cmd, sizeof (cmd) - 1, "dpt=%d", tid);
if (cmd_cb (core_ptr, cmd, NULL, 0) < 0) {
send_msg (g, "E01");
return -1;
}
return send_msg (g, "OK");
}
| 13,531 |
95,642 | 0 | static void CL_Cache_EndGather_f( void ) {
int i, j, handle, cachePass;
char filename[MAX_QPATH];
cachePass = (int)floor( (float)cacheIndex * CACHE_HIT_RATIO );
for ( i = 0; i < CACHE_NUMGROUPS; i++ ) {
Q_strncpyz( filename, cacheGroups[i].name, MAX_QPATH );
Q_strcat( filename, MAX_QPATH, ".cache" );
handle = FS_FOpenFileWrite( filename );
for ( j = 0; j < MAX_CACHE_ITEMS; j++ ) {
if ( cacheItems[i][j].hits >= cachePass && strstr( cacheItems[i][j].name, "/" ) ) {
FS_Write( cacheItems[i][j].name, strlen( cacheItems[i][j].name ), handle );
FS_Write( "\n", 1, handle );
}
}
FS_FCloseFile( handle );
}
Cvar_Set( "cl_cacheGathering", "0" );
}
| 13,532 |
146,388 | 0 | void WebGLRenderingContextBase::TexImageHelperHTMLVideoElement(
SecurityOrigin* security_origin,
TexImageFunctionID function_id,
GLenum target,
GLint level,
GLint internalformat,
GLenum format,
GLenum type,
GLint xoffset,
GLint yoffset,
GLint zoffset,
HTMLVideoElement* video,
const IntRect& source_image_rect,
GLsizei depth,
GLint unpack_image_height,
ExceptionState& exception_state) {
const char* func_name = GetTexImageFunctionName(function_id);
if (isContextLost())
return;
if (!ValidateHTMLVideoElement(security_origin, func_name, video,
exception_state))
return;
WebGLTexture* texture =
ValidateTexImageBinding(func_name, function_id, target);
if (!texture)
return;
TexImageFunctionType function_type;
if (function_id == kTexImage2D || function_id == kTexImage3D)
function_type = kTexImage;
else
function_type = kTexSubImage;
if (!ValidateTexFunc(func_name, function_type, kSourceHTMLVideoElement,
target, level, internalformat, video->videoWidth(),
video->videoHeight(), 1, 0, format, type, xoffset,
yoffset, zoffset))
return;
bool source_image_rect_is_default =
source_image_rect == SentinelEmptyRect() ||
source_image_rect ==
IntRect(0, 0, video->videoWidth(), video->videoHeight());
const bool use_copyTextureCHROMIUM = function_id == kTexImage2D &&
source_image_rect_is_default &&
depth == 1 && GL_TEXTURE_2D == target &&
CanUseTexImageByGPU(format, type);
if (use_copyTextureCHROMIUM) {
DCHECK_EQ(xoffset, 0);
DCHECK_EQ(yoffset, 0);
DCHECK_EQ(zoffset, 0);
if (video->CopyVideoTextureToPlatformTexture(
ContextGL(), target, texture->Object(), internalformat, format,
type, level, unpack_premultiply_alpha_, unpack_flip_y_)) {
texture->UpdateLastUploadedVideo(video->GetWebMediaPlayer());
return;
}
}
if (source_image_rect_is_default) {
ScopedUnpackParametersResetRestore(
this, unpack_flip_y_ || unpack_premultiply_alpha_);
if (video->TexImageImpl(
static_cast<WebMediaPlayer::TexImageFunctionID>(function_id),
target, ContextGL(), texture->Object(), level,
ConvertTexInternalFormat(internalformat, type), format, type,
xoffset, yoffset, zoffset, unpack_flip_y_,
unpack_premultiply_alpha_ &&
unpack_colorspace_conversion_ == GL_NONE)) {
texture->UpdateLastUploadedVideo(video->GetWebMediaPlayer());
return;
}
}
if (use_copyTextureCHROMIUM) {
std::unique_ptr<ImageBufferSurface> surface =
WTF::WrapUnique(new AcceleratedImageBufferSurface(
IntSize(video->videoWidth(), video->videoHeight())));
if (surface->IsValid()) {
std::unique_ptr<ImageBuffer> image_buffer(
ImageBuffer::Create(std::move(surface)));
if (image_buffer) {
video->PaintCurrentFrame(
image_buffer->Canvas(),
IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr);
TexImage2DBase(target, level, internalformat, video->videoWidth(),
video->videoHeight(), 0, format, type, nullptr);
if (image_buffer->CopyToPlatformTexture(
FunctionIDToSnapshotReason(function_id), ContextGL(), target,
texture->Object(), unpack_premultiply_alpha_, unpack_flip_y_,
IntPoint(0, 0),
IntRect(0, 0, video->videoWidth(), video->videoHeight()))) {
texture->UpdateLastUploadedVideo(video->GetWebMediaPlayer());
return;
}
}
}
}
RefPtr<Image> image = VideoFrameToImage(video);
if (!image)
return;
TexImageImpl(function_id, target, level, internalformat, xoffset, yoffset,
zoffset, format, type, image.Get(),
WebGLImageConversion::kHtmlDomVideo, unpack_flip_y_,
unpack_premultiply_alpha_, source_image_rect, depth,
unpack_image_height);
texture->UpdateLastUploadedVideo(video->GetWebMediaPlayer());
}
| 13,533 |
25,147 | 0 | static int rt_bind_neighbour(struct rtable *rt)
{
struct neighbour *n = ipv4_neigh_lookup(&rt->dst, &rt->rt_gateway);
if (IS_ERR(n))
return PTR_ERR(n);
dst_set_neighbour(&rt->dst, n);
return 0;
}
| 13,534 |
47,066 | 0 | static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
struct scatterlist *src, unsigned int nbytes)
{
struct twofish_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
be128 buf[TWOFISH_PARALLEL_BLOCKS];
struct crypt_priv crypt_ctx = {
.ctx = &ctx->twofish_ctx,
.fpu_enabled = false,
};
struct lrw_crypt_req req = {
.tbuf = buf,
.tbuflen = sizeof(buf),
.table_ctx = &ctx->lrw_table,
.crypt_ctx = &crypt_ctx,
.crypt_fn = decrypt_callback,
};
int ret;
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
ret = lrw_crypt(desc, dst, src, nbytes, &req);
twofish_fpu_end(crypt_ctx.fpu_enabled);
return ret;
}
| 13,535 |
122,482 | 0 | void InspectorController::scriptsEnabled(bool enabled)
{
if (InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgent())
pageAgent->scriptsEnabled(enabled);
}
| 13,536 |
80,290 | 0 | GF_Err nmhd_Write(GF_Box *s, GF_BitStream *bs)
{
return gf_isom_full_box_write(s, bs);
}
| 13,537 |
92,335 | 0 | hashTableClear(HASH_TABLE *table)
{
size_t i;
for (i = 0; i < table->size; i++) {
table->mem->free_fcn(table->v[i]);
table->v[i] = NULL;
}
table->used = 0;
}
| 13,538 |
69,392 | 0 | __releases(ping_table.lock)
{
read_unlock_bh(&ping_table.lock);
}
| 13,539 |
162,155 | 0 | UnmatchedServiceWorkerProcessTracker() {}
| 13,540 |
104,126 | 0 | error::Error GLES2DecoderImpl::HandleGetActiveUniform(
uint32 immediate_data_size, const gles2::GetActiveUniform& c) {
GLuint program = c.program;
GLuint index = c.index;
uint32 name_bucket_id = c.name_bucket_id;
typedef gles2::GetActiveUniform::Result Result;
Result* result = GetSharedMemoryAs<Result*>(
c.result_shm_id, c.result_shm_offset, sizeof(*result));
if (!result) {
return error::kOutOfBounds;
}
if (result->success != 0) {
return error::kInvalidArguments;
}
ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
program, "glGetActiveUniform");
if (!info) {
return error::kNoError;
}
const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
info->GetUniformInfo(index);
if (!uniform_info) {
SetGLError(GL_INVALID_VALUE, "glGetActiveUniform: index out of range");
return error::kNoError;
}
result->success = 1; // true.
result->size = uniform_info->size;
result->type = uniform_info->type;
Bucket* bucket = CreateBucket(name_bucket_id);
bucket->SetFromString(uniform_info->name.c_str());
return error::kNoError;
}
| 13,541 |
33,714 | 0 | SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set)
{
return do_sigpending(set, sizeof(*set));
}
| 13,542 |
61,267 | 0 | static char *mboxlist_entry_cstring(const mbentry_t *mbentry)
{
struct buf buf = BUF_INITIALIZER;
struct dlist *dl = dlist_newkvlist(NULL, mbentry->name);
if (mbentry->acl)
_write_acl(dl, mbentry->acl);
if (mbentry->uniqueid)
dlist_setatom(dl, "I", mbentry->uniqueid);
if (mbentry->partition)
dlist_setatom(dl, "P", mbentry->partition);
if (mbentry->server)
dlist_setatom(dl, "S", mbentry->server);
if (mbentry->mbtype)
dlist_setatom(dl, "T", mboxlist_mbtype_to_string(mbentry->mbtype));
if (mbentry->uidvalidity)
dlist_setnum32(dl, "V", mbentry->uidvalidity);
if (mbentry->foldermodseq)
dlist_setnum64(dl, "F", mbentry->foldermodseq);
dlist_setdate(dl, "M", time(NULL));
dlist_printbuf(dl, 0, &buf);
dlist_free(&dl);
return buf_release(&buf);
}
| 13,543 |
20,009 | 0 | static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl, u32 max_reqs,
u32 ivalue)
{
struct nfs4_slot *new = NULL;
int ret = -ENOMEM;
dprintk("--> %s: max_reqs=%u, tbl->max_slots %d\n", __func__,
max_reqs, tbl->max_slots);
/* Does the newly negotiated max_reqs match the existing slot table? */
if (max_reqs != tbl->max_slots) {
new = nfs4_alloc_slots(max_reqs, GFP_NOFS);
if (!new)
goto out;
}
ret = 0;
nfs4_add_and_init_slots(tbl, new, max_reqs, ivalue);
dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
tbl, tbl->slots, tbl->max_slots);
out:
dprintk("<-- %s: return %d\n", __func__, ret);
return ret;
}
| 13,544 |
77,612 | 0 | ofputil_format_version_bitmap__(struct ds *msg, uint32_t bitmap,
void (*format_version)(struct ds *msg,
enum ofp_version))
{
while (bitmap) {
format_version(msg, raw_ctz(bitmap));
bitmap = zero_rightmost_1bit(bitmap);
if (bitmap) {
ds_put_cstr(msg, ", ");
}
}
}
| 13,545 |
95,206 | 0 | static void freefieldlist(struct fieldlist *l)
{
struct fieldlist *n;
while (l) {
n = l->next;
free(l->section);
strarray_free(l->fields);
free(l->trail);
if (l->rock) free(l->rock);
free((char *)l);
l = n;
}
}
| 13,546 |
6,508 | 0 | _bdf_list_done( _bdf_list_t* list )
{
FT_Memory memory = list->memory;
if ( memory )
{
FT_FREE( list->field );
FT_ZERO( list );
}
}
| 13,547 |
118,000 | 0 | void V8Proxy::registerExtension(v8::Extension* extension)
{
registerExtensionWithV8(extension);
staticExtensionsList().append(extension);
}
| 13,548 |
415 | 0 | icc_base_conv_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_colorspace *prf, const fz_default_colorspaces *default_cs, const fz_color_params *color_params, int copy_spots)
{
fz_colorspace *srcs = src->colorspace;
fz_colorspace *base_cs = get_base_icc_space(ctx, srcs);
int i, j;
unsigned char *inputpos, *outputpos;
fz_pixmap *base;
fz_irect bbox;
int h, len;
float src_f[FZ_MAX_COLORS], des_f[FZ_MAX_COLORS];
int sn = src->n;
int sc = sn - src->alpha - src->s;
int stride_src = src->stride - src->w * sn;
int stride_base;
int bn, bc;
base = fz_new_pixmap_with_bbox(ctx, base_cs, fz_pixmap_bbox(ctx, src, &bbox), src->seps, src->alpha);
bn = base->n;
bc = base->n - base->alpha - base->s;
stride_base = base->stride - base->w * bn;
inputpos = src->samples;
outputpos = base->samples;
h = src->h;
while (h--)
{
len = src->w;
while (len--)
{
/* Convert the actual colors */
for (i = 0; i < sc; i++)
src_f[i] = (float) inputpos[i] / 255.0f;
convert_to_icc_base(ctx, srcs, src_f, des_f);
base_cs->clamp(base_cs, des_f, des_f);
for (j = 0; j < bc; j++)
outputpos[j] = des_f[j] * 255.0f;
/* Copy spots and alphas unchanged */
for (; i < sn; i++, j++)
outputpos[j] = inputpos[i];
outputpos += bn;
inputpos += sn;
}
outputpos += stride_base;
inputpos += stride_src;
}
fz_try(ctx)
icc_conv_pixmap(ctx, dst, base, prf, default_cs, color_params, copy_spots);
fz_always(ctx)
fz_drop_pixmap(ctx, base);
fz_catch(ctx)
fz_rethrow(ctx);
}
| 13,549 |
188,522 | 1 | void update_rate_histogram(struct rate_hist *hist,
const vpx_codec_enc_cfg_t *cfg,
const vpx_codec_cx_pkt_t *pkt) {
int i;
int64_t then = 0;
int64_t avg_bitrate = 0;
int64_t sum_sz = 0;
const int64_t now = pkt->data.frame.pts * 1000 *
(uint64_t)cfg->g_timebase.num /
(uint64_t)cfg->g_timebase.den;
int idx = hist->frames++ % hist->samples;
hist->pts[idx] = now;
hist->sz[idx] = (int)pkt->data.frame.sz;
if (now < cfg->rc_buf_initial_sz)
return;
then = now;
/* Sum the size over the past rc_buf_sz ms */
for (i = hist->frames; i > 0 && hist->frames - i < hist->samples; i--) {
const int i_idx = (i - 1) % hist->samples;
then = hist->pts[i_idx];
if (now - then > cfg->rc_buf_sz)
break;
sum_sz += hist->sz[i_idx];
}
if (now == then)
return;
avg_bitrate = sum_sz * 8 * 1000 / (now - then);
idx = (int)(avg_bitrate * (RATE_BINS / 2) / (cfg->rc_target_bitrate * 1000));
if (idx < 0)
idx = 0;
if (idx > RATE_BINS - 1)
idx = RATE_BINS - 1;
if (hist->bucket[idx].low > avg_bitrate)
hist->bucket[idx].low = (int)avg_bitrate;
if (hist->bucket[idx].high < avg_bitrate)
hist->bucket[idx].high = (int)avg_bitrate;
hist->bucket[idx].count++;
hist->total++;
}
| 13,550 |
132,544 | 0 | ShellContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
return new ShellSpeechRecognitionManagerDelegate();
}
| 13,551 |
26,342 | 0 | static inline void schedule_debug(struct task_struct *prev)
{
/*
* Test if we are atomic. Since do_exit() needs to call into
* schedule() atomically, we ignore that path for now.
* Otherwise, whine if we are scheduling when we should not be.
*/
if (unlikely(in_atomic_preempt_off() && !prev->exit_state))
__schedule_bug(prev);
profile_hit(SCHED_PROFILING, __builtin_return_address(0));
schedstat_inc(this_rq(), sched_count);
}
| 13,552 |
125,608 | 0 | void RenderViewHostImpl::FilterURL(ChildProcessSecurityPolicyImpl* policy,
const RenderProcessHost* process,
bool empty_allowed,
GURL* url) {
if (empty_allowed && url->is_empty())
return;
DCHECK(GURL(kSwappedOutURL) != *url);
if (!url->is_valid()) {
*url = GURL(chrome::kAboutBlankURL);
return;
}
if (url->SchemeIs(chrome::kAboutScheme)) {
*url = GURL(chrome::kAboutBlankURL);
}
bool non_web_url_in_guest = process->IsGuest() &&
!(url->is_valid() && policy->IsWebSafeScheme(url->scheme()));
if (non_web_url_in_guest || !policy->CanRequestURL(process->GetID(), *url)) {
VLOG(1) << "Blocked URL " << url->spec();
*url = GURL(chrome::kAboutBlankURL);
}
}
| 13,553 |
104,151 | 0 | error::Error GLES2DecoderImpl::HandleShaderSource(
uint32 immediate_data_size, const gles2::ShaderSource& c) {
uint32 data_size = c.data_size;
const char* data = GetSharedMemoryAs<const char*>(
c.data_shm_id, c.data_shm_offset, data_size);
if (!data) {
return error::kOutOfBounds;
}
return ShaderSourceHelper(c.shader, data, data_size);
}
| 13,554 |
135,750 | 0 | bool InputMethodController::IsAvailable() const {
return GetFrame().GetDocument();
}
| 13,555 |
157,615 | 0 | explicit OneTimeCachingHostResolver(const HostPortPair& host_port)
: MockHostResolverBase(/* use_caching = */ true), host_port_(host_port) {}
| 13,556 |
126,147 | 0 | void BrowserLauncherItemController::OnRemoved() {
}
| 13,557 |
89,716 | 0 | static void nfc_llcp_rx_skb(struct nfc_llcp_local *local, struct sk_buff *skb)
{
u8 dsap, ssap, ptype;
ptype = nfc_llcp_ptype(skb);
dsap = nfc_llcp_dsap(skb);
ssap = nfc_llcp_ssap(skb);
pr_debug("ptype 0x%x dsap 0x%x ssap 0x%x\n", ptype, dsap, ssap);
if (ptype != LLCP_PDU_SYMM)
print_hex_dump_debug("LLCP Rx: ", DUMP_PREFIX_OFFSET, 16, 1,
skb->data, skb->len, true);
switch (ptype) {
case LLCP_PDU_SYMM:
pr_debug("SYMM\n");
break;
case LLCP_PDU_UI:
pr_debug("UI\n");
nfc_llcp_recv_ui(local, skb);
break;
case LLCP_PDU_CONNECT:
pr_debug("CONNECT\n");
nfc_llcp_recv_connect(local, skb);
break;
case LLCP_PDU_DISC:
pr_debug("DISC\n");
nfc_llcp_recv_disc(local, skb);
break;
case LLCP_PDU_CC:
pr_debug("CC\n");
nfc_llcp_recv_cc(local, skb);
break;
case LLCP_PDU_DM:
pr_debug("DM\n");
nfc_llcp_recv_dm(local, skb);
break;
case LLCP_PDU_SNL:
pr_debug("SNL\n");
nfc_llcp_recv_snl(local, skb);
break;
case LLCP_PDU_I:
case LLCP_PDU_RR:
case LLCP_PDU_RNR:
pr_debug("I frame\n");
nfc_llcp_recv_hdlc(local, skb);
break;
case LLCP_PDU_AGF:
pr_debug("AGF frame\n");
nfc_llcp_recv_agf(local, skb);
break;
}
}
| 13,558 |
145,823 | 0 | std::unique_ptr<base::DictionaryValue> HeadlessDevToolsManagerDelegate::Close(
content::DevToolsAgentHost* agent_host,
int session_id,
int command_id,
const base::DictionaryValue* params) {
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::BindOnce(&HeadlessBrowserImpl::Shutdown, browser_));
return CreateSuccessResponse(command_id, nullptr);
}
| 13,559 |
29,895 | 0 | gid_t from_kgid_munged(struct user_namespace *targ, kgid_t kgid)
{
gid_t gid;
gid = from_kgid(targ, kgid);
if (gid == (gid_t) -1)
gid = overflowgid;
return gid;
}
| 13,560 |
41,222 | 0 | static void tcp_try_to_open(struct sock *sk, int flag)
{
struct tcp_sock *tp = tcp_sk(sk);
tcp_verify_left_out(tp);
if (!tp->frto_counter && !tcp_any_retrans_done(sk))
tp->retrans_stamp = 0;
if (flag & FLAG_ECE)
tcp_enter_cwr(sk, 1);
if (inet_csk(sk)->icsk_ca_state != TCP_CA_CWR) {
tcp_try_keep_open(sk);
if (inet_csk(sk)->icsk_ca_state != TCP_CA_Open)
tcp_moderate_cwnd(tp);
} else {
tcp_cwnd_down(sk, flag);
}
}
| 13,561 |
120,944 | 0 | int SocketStream::DoSSLConnect() {
DCHECK(factory_);
SSLClientSocketContext ssl_context;
ssl_context.cert_verifier = context_->cert_verifier();
ssl_context.transport_security_state = context_->transport_security_state();
ssl_context.server_bound_cert_service = context_->server_bound_cert_service();
socket_.reset(factory_->CreateSSLClientSocket(socket_.release(),
HostPortPair::FromURL(url_),
server_ssl_config_,
ssl_context));
next_state_ = STATE_SSL_CONNECT_COMPLETE;
metrics_->OnCountConnectionType(SocketStreamMetrics::SSL_CONNECTION);
return socket_->Connect(io_callback_);
}
| 13,562 |
145,585 | 0 | void Splay56To64(const uint8_t* key_56, uint8_t* key_64) {
key_64[0] = key_56[0];
key_64[1] = key_56[0] << 7 | key_56[1] >> 1;
key_64[2] = key_56[1] << 6 | key_56[2] >> 2;
key_64[3] = key_56[2] << 5 | key_56[3] >> 3;
key_64[4] = key_56[3] << 4 | key_56[4] >> 4;
key_64[5] = key_56[4] << 3 | key_56[5] >> 5;
key_64[6] = key_56[5] << 2 | key_56[6] >> 6;
key_64[7] = key_56[6] << 1;
}
| 13,563 |
126,039 | 0 | IPC::Message* ExecuteBrowserCommandObserver::ReleaseReply() {
return reply_message_.release();
}
| 13,564 |
99,476 | 0 | static NPBool NPN_ConvertPoint(NPP instance, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double* destX, double* destY, NPCoordinateSpace destSpace)
{
notImplemented();
return false;
}
| 13,565 |
124,351 | 0 | void MessageService::PendingOpenChannel(scoped_ptr<OpenChannelParams> params,
int source_process_id,
ExtensionHost* host) {
if (!host)
return; // TODO(mpcomplete): notify source of disconnect?
content::RenderProcessHost* source =
content::RenderProcessHost::FromID(source_process_id);
if (!source)
return;
params->source = source;
params->receiver.reset(new ExtensionMessagePort(host->render_process_host(),
MSG_ROUTING_CONTROL,
params->target_extension_id));
OpenChannelImpl(params.Pass());
}
| 13,566 |
14,060 | 0 | static int ProcRenderCreateConicalGradient (ClientPtr client)
{
PicturePtr pPicture;
int len;
int error = 0;
xFixed *stops;
xRenderColor *colors;
REQUEST(xRenderCreateConicalGradientReq);
REQUEST_AT_LEAST_SIZE(xRenderCreateConicalGradientReq);
LEGAL_NEW_RESOURCE(stuff->pid, client);
len = (client->req_len << 2) - sizeof(xRenderCreateConicalGradientReq);
if (len != stuff->nStops*(sizeof(xFixed) + sizeof(xRenderColor)))
return BadLength;
stops = (xFixed *)(stuff + 1);
colors = (xRenderColor *)(stops + stuff->nStops);
pPicture = CreateConicalGradientPicture (stuff->pid, &stuff->center, stuff->angle,
stuff->nStops, stops, colors, &error);
if (!pPicture)
return error;
/* security creation/labeling check */
error = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, PictureType,
pPicture, RT_NONE, NULL, DixCreateAccess);
if (error != Success)
return error;
if (!AddResource (stuff->pid, PictureType, (pointer)pPicture))
return BadAlloc;
return Success;
}
| 13,567 |
3,621 | 0 | static int rsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
{
const unsigned char *p;
int pklen;
RSA *rsa = NULL;
if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, NULL, pubkey))
return 0;
if (!(rsa = d2i_RSAPublicKey(NULL, &p, pklen))) {
RSAerr(RSA_F_RSA_PUB_DECODE, ERR_R_RSA_LIB);
return 0;
}
EVP_PKEY_assign_RSA(pkey, rsa);
return 1;
}
| 13,568 |
159,803 | 0 | bool XSSAuditor::FilterInputToken(const FilterTokenRequest& request) {
DCHECK_EQ(request.token.GetType(), HTMLToken::kStartTag);
DCHECK(HasName(request.token, inputTag));
return EraseAttributeIfInjected(request, formactionAttr, kURLWithUniqueOrigin,
kSrcLikeAttributeTruncation);
}
| 13,569 |
42,139 | 0 | mm_auth_rhosts_rsa_key_allowed(struct passwd *pw, char *user,
char *host, Key *key)
{
int ret;
key->type = KEY_RSA; /* XXX hack for key_to_blob */
ret = mm_key_allowed(MM_RSAHOSTKEY, user, host, key, 0);
key->type = KEY_RSA1;
return (ret);
}
| 13,570 |
100,127 | 0 | void BrowserActionsContainer::OnResize(int resize_amount, bool done_resizing) {
if (!done_resizing) {
resize_amount_ = resize_amount;
OnBrowserActionVisibilityChanged();
} else {
int new_width = std::max(0, container_size_.width() - resize_amount);
int max_width = ClampToNearestIconCount(-1);
new_width = std::min(new_width, max_width);
container_size_.set_width(new_width);
animation_target_size_ = ClampToNearestIconCount(new_width);
resize_animation_->Reset();
resize_animation_->SetTweenType(SlideAnimation::EASE_OUT);
resize_animation_->Show();
}
}
| 13,571 |
67,933 | 0 | jas_stream_t *jas_stream_tmpfile()
{
jas_stream_t *stream;
jas_stream_fileobj_t *obj;
JAS_DBGLOG(100, ("jas_stream_tmpfile()\n"));
if (!(stream = jas_stream_create())) {
return 0;
}
/* A temporary file stream is always opened for both reading and
writing in binary mode. */
stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY;
/* Allocate memory for the underlying temporary file object. */
if (!(obj = jas_malloc(sizeof(jas_stream_fileobj_t)))) {
jas_stream_destroy(stream);
return 0;
}
obj->fd = -1;
obj->flags = 0;
obj->pathname[0] = '\0';
stream->obj_ = obj;
/* Choose a file name. */
tmpnam(obj->pathname);
/* Open the underlying file. */
if ((obj->fd = open(obj->pathname, O_CREAT | O_EXCL | O_RDWR | O_TRUNC | O_BINARY,
JAS_STREAM_PERMS)) < 0) {
jas_stream_destroy(stream);
return 0;
}
/* Unlink the file so that it will disappear if the program
terminates abnormally. */
/* Under UNIX, one can unlink an open file and continue to do I/O
on it. Not all operating systems support this functionality, however.
For example, under Microsoft Windows the unlink operation will fail,
since the file is open. */
if (unlink(obj->pathname)) {
/* We will try unlinking the file again after it is closed. */
obj->flags |= JAS_STREAM_FILEOBJ_DELONCLOSE;
}
/* Use full buffering. */
jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);
stream->ops_ = &jas_stream_fileops;
return stream;
}
| 13,572 |
86,268 | 0 | static void __unregister_pernet_operations(struct pernet_operations *ops)
{
struct net *net;
LIST_HEAD(net_exit_list);
list_del(&ops->list);
for_each_net(net)
list_add_tail(&net->exit_list, &net_exit_list);
ops_exit_list(ops, &net_exit_list);
ops_free_list(ops, &net_exit_list);
}
| 13,573 |
147,336 | 0 | static void DeprecateAsSameValueOverloadedMethod1Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestObject* impl = V8TestObject::ToImpl(info.Holder());
impl->DeprecateAsSameValueOverloadedMethod();
}
| 13,574 |
98,005 | 0 | void RenderView::OnUndo() {
if (!webview())
return;
webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo"));
UserMetricsRecordAction("Undo");
}
| 13,575 |
61,313 | 0 | static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
{
int i;
av_bprintf(bp, "0X");
for (i = 0; i < ubuf_size; i++)
av_bprintf(bp, "%02X", ubuf[i]);
}
| 13,576 |
147,410 | 0 | void V8TestObject::HTMLElementAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_htmlElementAttribute_Getter");
test_object_v8_internal::HTMLElementAttributeAttributeGetter(info);
}
| 13,577 |
149,514 | 0 | bool LoadingDataCollector::IsHandledResourceType(
content::ResourceType resource_type,
const std::string& mime_type) {
content::ResourceType actual_resource_type =
GetResourceType(resource_type, mime_type);
return actual_resource_type == content::ResourceType::kMainFrame ||
actual_resource_type == content::ResourceType::kStylesheet ||
actual_resource_type == content::ResourceType::kScript ||
actual_resource_type == content::ResourceType::kImage ||
actual_resource_type == content::ResourceType::kFontResource;
}
| 13,578 |
181,172 | 1 | static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
const uint8_t *buf, int buf_size,
int first_field)
{
int i, cid, ret;
int old_bit_depth = ctx->bit_depth, bitdepth;
uint64_t header_prefix;
if (buf_size < 0x280) {
av_log(ctx->avctx, AV_LOG_ERROR,
"buffer too small (%d < 640).\n", buf_size);
return AVERROR_INVALIDDATA;
}
header_prefix = ff_dnxhd_parse_header_prefix(buf);
if (header_prefix == 0) {
av_log(ctx->avctx, AV_LOG_ERROR,
"unknown header 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n",
buf[0], buf[1], buf[2], buf[3], buf[4]);
return AVERROR_INVALIDDATA;
}
if (buf[5] & 2) { /* interlaced */
ctx->cur_field = buf[5] & 1;
frame->interlaced_frame = 1;
frame->top_field_first = first_field ^ ctx->cur_field;
av_log(ctx->avctx, AV_LOG_DEBUG,
"interlaced %d, cur field %d\n", buf[5] & 3, ctx->cur_field);
} else {
ctx->cur_field = 0;
}
ctx->mbaff = (buf[0x6] >> 5) & 1;
ctx->height = AV_RB16(buf + 0x18);
ctx->width = AV_RB16(buf + 0x1a);
switch(buf[0x21] >> 5) {
case 1: bitdepth = 8; break;
case 2: bitdepth = 10; break;
case 3: bitdepth = 12; break;
default:
av_log(ctx->avctx, AV_LOG_ERROR,
"Unknown bitdepth indicator (%d)\n", buf[0x21] >> 5);
return AVERROR_INVALIDDATA;
}
cid = AV_RB32(buf + 0x28);
ctx->avctx->profile = dnxhd_get_profile(cid);
if ((ret = dnxhd_init_vlc(ctx, cid, bitdepth)) < 0)
return ret;
if (ctx->mbaff && ctx->cid_table->cid != 1260)
av_log(ctx->avctx, AV_LOG_WARNING,
"Adaptive MB interlace flag in an unsupported profile.\n");
ctx->act = buf[0x2C] & 7;
if (ctx->act && ctx->cid_table->cid != 1256 && ctx->cid_table->cid != 1270)
av_log(ctx->avctx, AV_LOG_WARNING,
"Adaptive color transform in an unsupported profile.\n");
ctx->is_444 = (buf[0x2C] >> 6) & 1;
if (ctx->is_444) {
if (bitdepth == 8) {
avpriv_request_sample(ctx->avctx, "4:4:4 8 bits");
return AVERROR_INVALIDDATA;
} else if (bitdepth == 10) {
ctx->decode_dct_block = dnxhd_decode_dct_block_10_444;
ctx->pix_fmt = ctx->act ? AV_PIX_FMT_YUV444P10
: AV_PIX_FMT_GBRP10;
} else {
ctx->decode_dct_block = dnxhd_decode_dct_block_12_444;
ctx->pix_fmt = ctx->act ? AV_PIX_FMT_YUV444P12
: AV_PIX_FMT_GBRP12;
}
} else if (bitdepth == 12) {
ctx->decode_dct_block = dnxhd_decode_dct_block_12;
ctx->pix_fmt = AV_PIX_FMT_YUV422P12;
} else if (bitdepth == 10) {
if (ctx->avctx->profile == FF_PROFILE_DNXHR_HQX)
ctx->decode_dct_block = dnxhd_decode_dct_block_10_444;
else
ctx->decode_dct_block = dnxhd_decode_dct_block_10;
ctx->pix_fmt = AV_PIX_FMT_YUV422P10;
} else {
ctx->decode_dct_block = dnxhd_decode_dct_block_8;
ctx->pix_fmt = AV_PIX_FMT_YUV422P;
}
ctx->avctx->bits_per_raw_sample = ctx->bit_depth = bitdepth;
if (ctx->bit_depth != old_bit_depth) {
ff_blockdsp_init(&ctx->bdsp, ctx->avctx);
ff_idctdsp_init(&ctx->idsp, ctx->avctx);
ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable,
ff_zigzag_direct);
}
// make sure profile size constraints are respected
// DNx100 allows 1920->1440 and 1280->960 subsampling
if (ctx->width != ctx->cid_table->width &&
ctx->cid_table->width != DNXHD_VARIABLE) {
av_reduce(&ctx->avctx->sample_aspect_ratio.num,
&ctx->avctx->sample_aspect_ratio.den,
ctx->width, ctx->cid_table->width, 255);
ctx->width = ctx->cid_table->width;
}
if (buf_size < ctx->cid_table->coding_unit_size) {
av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size (%d < %u).\n",
buf_size, ctx->cid_table->coding_unit_size);
return AVERROR_INVALIDDATA;
}
ctx->mb_width = (ctx->width + 15)>> 4;
ctx->mb_height = AV_RB16(buf + 0x16c);
if ((ctx->height + 15) >> 4 == ctx->mb_height && frame->interlaced_frame)
ctx->height <<= 1;
av_log(ctx->avctx, AV_LOG_VERBOSE, "%dx%d, 4:%s %d bits, MBAFF=%d ACT=%d\n",
ctx->width, ctx->height, ctx->is_444 ? "4:4" : "2:2",
ctx->bit_depth, ctx->mbaff, ctx->act);
// Newer format supports variable mb_scan_index sizes
if (ctx->mb_height > 68 && ff_dnxhd_check_header_prefix_hr(header_prefix)) {
ctx->data_offset = 0x170 + (ctx->mb_height << 2);
} else {
if (ctx->mb_height > 68 ||
(ctx->mb_height << frame->interlaced_frame) > (ctx->height + 15) >> 4) {
av_log(ctx->avctx, AV_LOG_ERROR,
"mb height too big: %d\n", ctx->mb_height);
return AVERROR_INVALIDDATA;
}
ctx->data_offset = 0x280;
}
if (buf_size < ctx->data_offset) {
av_log(ctx->avctx, AV_LOG_ERROR,
"buffer too small (%d < %d).\n", buf_size, ctx->data_offset);
return AVERROR_INVALIDDATA;
}
if (ctx->mb_height > FF_ARRAY_ELEMS(ctx->mb_scan_index)) {
av_log(ctx->avctx, AV_LOG_ERROR,
"mb_height too big (%d > %"SIZE_SPECIFIER").\n", ctx->mb_height, FF_ARRAY_ELEMS(ctx->mb_scan_index));
return AVERROR_INVALIDDATA;
}
for (i = 0; i < ctx->mb_height; i++) {
ctx->mb_scan_index[i] = AV_RB32(buf + 0x170 + (i << 2));
ff_dlog(ctx->avctx, "mb scan index %d, pos %d: %"PRIu32"\n",
i, 0x170 + (i << 2), ctx->mb_scan_index[i]);
if (buf_size - ctx->data_offset < ctx->mb_scan_index[i]) {
av_log(ctx->avctx, AV_LOG_ERROR,
"invalid mb scan index (%"PRIu32" vs %u).\n",
ctx->mb_scan_index[i], buf_size - ctx->data_offset);
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| 13,579 |
54,973 | 0 | void add_reflogs_to_pending(struct rev_info *revs, unsigned flags)
{
struct all_refs_cb cb;
cb.all_revs = revs;
cb.all_flags = flags;
for_each_reflog(handle_one_reflog, &cb);
}
| 13,580 |
145,533 | 0 | void ResourceDispatcherHostImpl::UpdateLoadInfo() {
scoped_ptr<LoadInfoMap> info_map(GetLoadInfoForAllRoutes());
if (info_map->empty() || !scheduler_->HasLoadingClients()) {
update_load_states_timer_->Stop();
return;
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&ResourceDispatcherHostImpl::UpdateLoadInfoOnUIThread,
base::Passed(&info_map)));
}
| 13,581 |
120,901 | 0 | ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(
Profile* profile,
const ProfileIOData* profile_io_data,
const StoragePartitionDescriptor& partition_descriptor,
scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
protocol_handler_interceptor,
content::ProtocolHandlerMap* protocol_handlers) {
DCHECK(profile->IsOffTheRecord());
ChromeURLRequestContextGetter* main_context =
static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
return new ChromeURLRequestContextGetter(
new FactoryForIsolatedApp(profile_io_data, partition_descriptor,
main_context,
protocol_handler_interceptor.Pass(),
protocol_handlers));
}
| 13,582 |
14,481 | 0 | static inline uint16_t vring_avail_flags(VirtQueue *vq)
{
hwaddr pa;
pa = vq->vring.avail + offsetof(VRingAvail, flags);
return lduw_phys(&address_space_memory, pa);
}
| 13,583 |
51,656 | 0 | static void airspy_disconnect(struct usb_interface *intf)
{
struct v4l2_device *v = usb_get_intfdata(intf);
struct airspy *s = container_of(v, struct airspy, v4l2_dev);
dev_dbg(s->dev, "\n");
mutex_lock(&s->vb_queue_lock);
mutex_lock(&s->v4l2_lock);
/* No need to keep the urbs around after disconnection */
s->udev = NULL;
v4l2_device_disconnect(&s->v4l2_dev);
video_unregister_device(&s->vdev);
mutex_unlock(&s->v4l2_lock);
mutex_unlock(&s->vb_queue_lock);
v4l2_device_put(&s->v4l2_dev);
}
| 13,584 |
106,629 | 0 | void WebPageProxy::setIsResizable(bool isResizable)
{
m_uiClient.setIsResizable(this, isResizable);
}
| 13,585 |
16,353 | 0 | BaseShadow::terminateJob( update_style_t kind ) // has a default argument of US_NORMAL
{
int reason;
bool signaled;
MyString str;
if( ! jobAd ) {
dprintf( D_ALWAYS, "In terminateJob() w/ NULL JobAd!" );
}
/* The first thing we do is record that we are in a termination pending
state. */
if (kind == US_NORMAL) {
str.sprintf("%s = TRUE", ATTR_TERMINATION_PENDING);
jobAd->Insert(str.Value());
}
if (kind == US_TERMINATE_PENDING) {
int exited_by_signal = FALSE;
int exit_signal = 0;
int exit_code = 0;
getJobAdExitedBySignal(jobAd, exited_by_signal);
if (exited_by_signal == TRUE) {
getJobAdExitSignal(jobAd, exit_signal);
} else {
getJobAdExitCode(jobAd, exit_code);
}
if (exited_by_signal == TRUE) {
reason = JOB_COREDUMPED;
str.sprintf("%s = \"%s\"", ATTR_JOB_CORE_FILENAME, core_file_name);
jobAd->Insert(str.Value());
} else {
reason = JOB_EXITED;
}
dprintf( D_ALWAYS, "Job %d.%d terminated: %s %d\n",
getCluster(), getProc(),
exited_by_signal? "killed by signal" : "exited with status",
exited_by_signal ? exit_signal : exit_code );
logTerminateEvent( reason, kind );
emailTerminateEvent( reason, kind );
DC_Exit( reason );
}
cleanUp();
reason = getExitReason();
signaled = exitedBySignal();
/* also store the corefilename into the jobad so we can recover this
during a termination pending scenario. */
if( reason == JOB_COREDUMPED ) {
str.sprintf("%s = \"%s\"", ATTR_JOB_CORE_FILENAME, getCoreName());
jobAd->Insert(str.Value());
}
int last_ckpt_time = 0;
jobAd->LookupInteger(ATTR_LAST_CKPT_TIME, last_ckpt_time);
int current_start_time = 0;
jobAd->LookupInteger(ATTR_JOB_CURRENT_START_DATE, current_start_time);
int int_value = (last_ckpt_time > current_start_time) ?
last_ckpt_time : current_start_time;
if( int_value > 0 ) {
int job_committed_time = 0;
jobAd->LookupInteger(ATTR_JOB_COMMITTED_TIME, job_committed_time);
int delta = (int)time(NULL) - int_value;
job_committed_time += delta;
jobAd->Assign(ATTR_JOB_COMMITTED_TIME, job_committed_time);
float slot_weight = 1;
jobAd->LookupFloat(ATTR_JOB_MACHINE_ATTR_SLOT_WEIGHT0, slot_weight);
float slot_time = 0;
jobAd->LookupFloat(ATTR_COMMITTED_SLOT_TIME, slot_time);
slot_time += slot_weight * delta;
jobAd->Assign(ATTR_COMMITTED_SLOT_TIME, slot_time);
}
CommitSuspensionTime(jobAd);
if (m_num_cleanup_retries < 1 &&
param_boolean("SHADOW_TEST_JOB_CLEANUP_RETRY", false)) {
dprintf( D_ALWAYS,
"Testing Failure to perform final update to job queue!\n");
retryJobCleanup();
return;
}
if( !updateJobInQueue(U_TERMINATE) ) {
dprintf( D_ALWAYS,
"Failed to perform final update to job queue!\n");
retryJobCleanup();
return;
}
dprintf( D_ALWAYS, "Job %d.%d terminated: %s %d\n",
getCluster(), getProc(),
signaled ? "killed by signal" : "exited with status",
signaled ? exitSignal() : exitCode() );
logTerminateEvent( reason );
emailTerminateEvent( reason );
if( reason == JOB_EXITED && claimIsClosing() ) {
dprintf(D_FULLDEBUG,"Startd is closing claim, so no more jobs can be run on it.\n");
reason = JOB_EXITED_AND_CLAIM_CLOSING;
}
if( recycleShadow(reason) ) {
return;
}
DC_Exit( reason );
}
| 13,586 |
7,340 | 0 | T1_ToString( PS_Parser parser )
{
return ps_tostring( &parser->cursor, parser->limit, parser->memory );
}
| 13,587 |
125,690 | 0 | void RenderViewHostImpl::OnSwapOutACK(bool timed_out) {
decrement_in_flight_event_count();
StopHangMonitorTimeout();
is_waiting_for_unload_ack_ = false;
has_timed_out_on_unload_ = timed_out;
delegate_->SwappedOut(this);
}
| 13,588 |
165,590 | 0 | WebFrameLoadType FrameLoader::DetermineFrameLoadType(
const ResourceRequest& resource_request,
Document* origin_document,
const KURL& failing_url,
WebFrameLoadType frame_load_type) {
if (frame_load_type == WebFrameLoadType::kStandard ||
frame_load_type == WebFrameLoadType::kReplaceCurrentItem) {
if (frame_->Tree().Parent() &&
!state_machine_.CommittedFirstRealDocumentLoad())
return WebFrameLoadType::kReplaceCurrentItem;
if (!frame_->Tree().Parent() && !Client()->BackForwardLength()) {
if (Opener() && resource_request.Url().IsEmpty())
return WebFrameLoadType::kReplaceCurrentItem;
return WebFrameLoadType::kStandard;
}
}
if (frame_load_type != WebFrameLoadType::kStandard)
return frame_load_type;
CHECK_NE(mojom::FetchCacheMode::kValidateCache,
resource_request.GetCacheMode());
CHECK_NE(mojom::FetchCacheMode::kBypassCache,
resource_request.GetCacheMode());
if ((!state_machine_.CommittedMultipleRealLoads() &&
DeprecatedEqualIgnoringCase(frame_->GetDocument()->Url(), BlankURL())))
return WebFrameLoadType::kReplaceCurrentItem;
if (resource_request.Url() == document_loader_->UrlForHistory()) {
if (resource_request.HttpMethod() == http_names::kPOST)
return WebFrameLoadType::kStandard;
if (!origin_document)
return WebFrameLoadType::kReload;
return WebFrameLoadType::kReplaceCurrentItem;
}
if (failing_url == document_loader_->UrlForHistory() &&
document_loader_->LoadType() == WebFrameLoadType::kReload)
return WebFrameLoadType::kReload;
if (resource_request.Url().IsEmpty() && failing_url.IsEmpty()) {
return WebFrameLoadType::kReplaceCurrentItem;
}
if (origin_document && !origin_document->CanCreateHistoryEntry())
return WebFrameLoadType::kReplaceCurrentItem;
return WebFrameLoadType::kStandard;
}
| 13,589 |
102,390 | 0 | string16 FormatViewSourceUrl(const GURL& url,
const std::vector<size_t>& original_offsets,
const std::string& languages,
FormatUrlTypes format_types,
UnescapeRule::Type unescape_rules,
url_parse::Parsed* new_parsed,
size_t* prefix_end,
std::vector<size_t>* offsets_for_adjustment) {
DCHECK(new_parsed);
const char kViewSource[] = "view-source:";
const size_t kViewSourceLength = arraysize(kViewSource) - 1;
std::vector<size_t> offsets_into_url(
OffsetsIntoComponent(original_offsets, kViewSourceLength));
GURL real_url(url.possibly_invalid_spec().substr(kViewSourceLength));
string16 result(ASCIIToUTF16(kViewSource) +
FormatUrlWithOffsets(real_url, languages, format_types, unescape_rules,
new_parsed, prefix_end, &offsets_into_url));
if (new_parsed->scheme.is_nonempty()) {
new_parsed->scheme.len += kViewSourceLength;
} else {
new_parsed->scheme.begin = 0;
new_parsed->scheme.len = kViewSourceLength - 1;
}
AdjustComponents(kViewSourceLength, new_parsed);
if (prefix_end)
*prefix_end += kViewSourceLength;
AdjustForComponentTransform(original_offsets, kViewSourceLength,
url.possibly_invalid_spec().length(), offsets_into_url, kViewSourceLength,
offsets_for_adjustment);
LimitOffsets(result, offsets_for_adjustment);
return result;
}
| 13,590 |
37,653 | 0 | static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
{
struct vmcs12 *vmcs12;
struct vcpu_vmx *vmx = to_vmx(vcpu);
int cpu;
struct loaded_vmcs *vmcs02;
bool ia32e;
if (!nested_vmx_check_permission(vcpu) ||
!nested_vmx_check_vmcs12(vcpu))
return 1;
skip_emulated_instruction(vcpu);
vmcs12 = get_vmcs12(vcpu);
if (enable_shadow_vmcs)
copy_shadow_to_vmcs12(vmx);
/*
* The nested entry process starts with enforcing various prerequisites
* on vmcs12 as required by the Intel SDM, and act appropriately when
* they fail: As the SDM explains, some conditions should cause the
* instruction to fail, while others will cause the instruction to seem
* to succeed, but return an EXIT_REASON_INVALID_STATE.
* To speed up the normal (success) code path, we should avoid checking
* for misconfigurations which will anyway be caught by the processor
* when using the merged vmcs02.
*/
if (vmcs12->launch_state == launch) {
nested_vmx_failValid(vcpu,
launch ? VMXERR_VMLAUNCH_NONCLEAR_VMCS
: VMXERR_VMRESUME_NONLAUNCHED_VMCS);
return 1;
}
if (vmcs12->guest_activity_state != GUEST_ACTIVITY_ACTIVE) {
nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD);
return 1;
}
if ((vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_MSR_BITMAPS) &&
!IS_ALIGNED(vmcs12->msr_bitmap, PAGE_SIZE)) {
/*TODO: Also verify bits beyond physical address width are 0*/
nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD);
return 1;
}
if (nested_cpu_has2(vmcs12, SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) &&
!IS_ALIGNED(vmcs12->apic_access_addr, PAGE_SIZE)) {
/*TODO: Also verify bits beyond physical address width are 0*/
nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD);
return 1;
}
if (vmcs12->vm_entry_msr_load_count > 0 ||
vmcs12->vm_exit_msr_load_count > 0 ||
vmcs12->vm_exit_msr_store_count > 0) {
pr_warn_ratelimited("%s: VMCS MSR_{LOAD,STORE} unsupported\n",
__func__);
nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD);
return 1;
}
if (!vmx_control_verify(vmcs12->cpu_based_vm_exec_control,
nested_vmx_procbased_ctls_low, nested_vmx_procbased_ctls_high) ||
!vmx_control_verify(vmcs12->secondary_vm_exec_control,
nested_vmx_secondary_ctls_low, nested_vmx_secondary_ctls_high) ||
!vmx_control_verify(vmcs12->pin_based_vm_exec_control,
nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high) ||
!vmx_control_verify(vmcs12->vm_exit_controls,
nested_vmx_exit_ctls_low, nested_vmx_exit_ctls_high) ||
!vmx_control_verify(vmcs12->vm_entry_controls,
nested_vmx_entry_ctls_low, nested_vmx_entry_ctls_high))
{
nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD);
return 1;
}
if (((vmcs12->host_cr0 & VMXON_CR0_ALWAYSON) != VMXON_CR0_ALWAYSON) ||
((vmcs12->host_cr4 & VMXON_CR4_ALWAYSON) != VMXON_CR4_ALWAYSON)) {
nested_vmx_failValid(vcpu,
VMXERR_ENTRY_INVALID_HOST_STATE_FIELD);
return 1;
}
if (((vmcs12->guest_cr0 & VMXON_CR0_ALWAYSON) != VMXON_CR0_ALWAYSON) ||
((vmcs12->guest_cr4 & VMXON_CR4_ALWAYSON) != VMXON_CR4_ALWAYSON)) {
nested_vmx_entry_failure(vcpu, vmcs12,
EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
return 1;
}
if (vmcs12->vmcs_link_pointer != -1ull) {
nested_vmx_entry_failure(vcpu, vmcs12,
EXIT_REASON_INVALID_STATE, ENTRY_FAIL_VMCS_LINK_PTR);
return 1;
}
/*
* If the load IA32_EFER VM-entry control is 1, the following checks
* are performed on the field for the IA32_EFER MSR:
* - Bits reserved in the IA32_EFER MSR must be 0.
* - Bit 10 (corresponding to IA32_EFER.LMA) must equal the value of
* the IA-32e mode guest VM-exit control. It must also be identical
* to bit 8 (LME) if bit 31 in the CR0 field (corresponding to
* CR0.PG) is 1.
*/
if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_EFER) {
ia32e = (vmcs12->vm_entry_controls & VM_ENTRY_IA32E_MODE) != 0;
if (!kvm_valid_efer(vcpu, vmcs12->guest_ia32_efer) ||
ia32e != !!(vmcs12->guest_ia32_efer & EFER_LMA) ||
((vmcs12->guest_cr0 & X86_CR0_PG) &&
ia32e != !!(vmcs12->guest_ia32_efer & EFER_LME))) {
nested_vmx_entry_failure(vcpu, vmcs12,
EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
return 1;
}
}
/*
* If the load IA32_EFER VM-exit control is 1, bits reserved in the
* IA32_EFER MSR must be 0 in the field for that register. In addition,
* the values of the LMA and LME bits in the field must each be that of
* the host address-space size VM-exit control.
*/
if (vmcs12->vm_exit_controls & VM_EXIT_LOAD_IA32_EFER) {
ia32e = (vmcs12->vm_exit_controls &
VM_EXIT_HOST_ADDR_SPACE_SIZE) != 0;
if (!kvm_valid_efer(vcpu, vmcs12->host_ia32_efer) ||
ia32e != !!(vmcs12->host_ia32_efer & EFER_LMA) ||
ia32e != !!(vmcs12->host_ia32_efer & EFER_LME)) {
nested_vmx_entry_failure(vcpu, vmcs12,
EXIT_REASON_INVALID_STATE, ENTRY_FAIL_DEFAULT);
return 1;
}
}
/*
* We're finally done with prerequisite checking, and can start with
* the nested entry.
*/
vmcs02 = nested_get_current_vmcs02(vmx);
if (!vmcs02)
return -ENOMEM;
enter_guest_mode(vcpu);
vmx->nested.vmcs01_tsc_offset = vmcs_read64(TSC_OFFSET);
cpu = get_cpu();
vmx->loaded_vmcs = vmcs02;
vmx_vcpu_put(vcpu);
vmx_vcpu_load(vcpu, cpu);
vcpu->cpu = cpu;
put_cpu();
vmx_segment_cache_clear(vmx);
vmcs12->launch_state = 1;
prepare_vmcs02(vcpu, vmcs12);
/*
* Note no nested_vmx_succeed or nested_vmx_fail here. At this point
* we are no longer running L1, and VMLAUNCH/VMRESUME has not yet
* returned as far as L1 is concerned. It will only return (and set
* the success flag) when L2 exits (see nested_vmx_vmexit()).
*/
return 1;
}
| 13,591 |
71,557 | 0 | static ssize_t ReadBlobBlock(Image *image,unsigned char *data)
{
ssize_t
count;
unsigned char
block_count;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
assert(data != (unsigned char *) NULL);
count=ReadBlob(image,1,&block_count);
if (count != 1)
return(0);
count=ReadBlob(image,(size_t) block_count,data);
if (count != (ssize_t) block_count)
return(0);
return(count);
}
| 13,592 |
18,995 | 0 | static void get_timewait4_sock(struct inet_timewait_sock *tw,
struct seq_file *f, int i, int *len)
{
__be32 dest, src;
__u16 destp, srcp;
int ttd = tw->tw_ttd - jiffies;
if (ttd < 0)
ttd = 0;
dest = tw->tw_daddr;
src = tw->tw_rcv_saddr;
destp = ntohs(tw->tw_dport);
srcp = ntohs(tw->tw_sport);
seq_printf(f, "%4d: %08X:%04X %08X:%04X"
" %02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p%n",
i, src, srcp, dest, destp, tw->tw_substate, 0, 0,
3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
atomic_read(&tw->tw_refcnt), tw, len);
}
| 13,593 |
50,367 | 0 | __posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
{
struct posix_acl *clone = posix_acl_clone(*acl, gfp);
int err = -ENOMEM;
if (clone) {
err = __posix_acl_chmod_masq(clone, mode);
if (err) {
posix_acl_release(clone);
clone = NULL;
}
}
posix_acl_release(*acl);
*acl = clone;
return err;
}
| 13,594 |
20,451 | 0 | void ext4_block_bitmap_set(struct super_block *sb,
struct ext4_group_desc *bg, ext4_fsblk_t blk)
{
bg->bg_block_bitmap_lo = cpu_to_le32((u32)blk);
if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
bg->bg_block_bitmap_hi = cpu_to_le32(blk >> 32);
}
| 13,595 |
69,570 | 0 | static int segmented_read_std(struct x86_emulate_ctxt *ctxt,
struct segmented_address addr,
void *data,
unsigned size)
{
int rc;
ulong linear;
rc = linearize(ctxt, addr, size, false, &linear);
if (rc != X86EMUL_CONTINUE)
return rc;
return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception);
}
| 13,596 |
125,099 | 0 | ChromePluginServiceFilter::~ChromePluginServiceFilter() {
}
| 13,597 |
182,117 | 1 | static int start_decoder(vorb *f)
{
uint8 header[6], x,y;
int len,i,j,k, max_submaps = 0;
int longest_floorlist=0;
// first page, first packet
if (!start_page(f)) return FALSE;
// validate page flag
if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page);
if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page);
if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
// check for expected packet length
if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page);
// read packet
// check packet header
if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof);
if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page);
// vorbis_version
if (get32(f) != 0) return error(f, VORBIS_invalid_first_page);
f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page);
if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels);
f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page);
get32(f); // bitrate_maximum
get32(f); // bitrate_nominal
get32(f); // bitrate_minimum
x = get8(f);
{
int log0,log1;
log0 = x & 15;
log1 = x >> 4;
f->blocksize_0 = 1 << log0;
f->blocksize_1 = 1 << log1;
if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup);
if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup);
if (log0 > log1) return error(f, VORBIS_invalid_setup);
}
// framing_flag
x = get8(f);
if (!(x & 1)) return error(f, VORBIS_invalid_first_page);
// second packet!
if (!start_page(f)) return FALSE;
if (!start_packet(f)) return FALSE;
do {
len = next_segment(f);
skip(f, len);
f->bytes_in_seg = 0;
} while (len);
// third packet!
if (!start_packet(f)) return FALSE;
#ifndef STB_VORBIS_NO_PUSHDATA_API
if (IS_PUSH_MODE(f)) {
if (!is_whole_packet_present(f, TRUE)) {
// convert error in ogg header to write type
if (f->error == VORBIS_invalid_stream)
f->error = VORBIS_invalid_setup;
return FALSE;
}
}
#endif
crc32_init(); // always init it, to avoid multithread race conditions
if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup);
for (i=0; i < 6; ++i) header[i] = get8_packet(f);
if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup);
// codebooks
f->codebook_count = get_bits(f,8) + 1;
f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count);
if (f->codebooks == NULL) return error(f, VORBIS_outofmem);
memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count);
for (i=0; i < f->codebook_count; ++i) {
uint32 *values;
int ordered, sorted_count;
int total=0;
uint8 *lengths;
Codebook *c = f->codebooks+i;
CHECK(f);
x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8);
c->dimensions = (get_bits(f, 8)<<8) + x;
x = get_bits(f, 8);
y = get_bits(f, 8);
c->entries = (get_bits(f, 8)<<16) + (y<<8) + x;
ordered = get_bits(f,1);
c->sparse = ordered ? 0 : get_bits(f,1);
if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup);
if (c->sparse)
lengths = (uint8 *) setup_temp_malloc(f, c->entries);
else
lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
if (!lengths) return error(f, VORBIS_outofmem);
if (ordered) {
int current_entry = 0;
int current_length = get_bits(f,5) + 1;
while (current_entry < c->entries) {
int limit = c->entries - current_entry;
int n = get_bits(f, ilog(limit));
if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); }
memset(lengths + current_entry, current_length, n);
current_entry += n;
++current_length;
}
} else {
for (j=0; j < c->entries; ++j) {
int present = c->sparse ? get_bits(f,1) : 1;
if (present) {
lengths[j] = get_bits(f, 5) + 1;
++total;
if (lengths[j] == 32)
return error(f, VORBIS_invalid_setup);
} else {
lengths[j] = NO_CODE;
}
}
}
if (c->sparse && total >= c->entries >> 2) {
// convert sparse items to non-sparse!
if (c->entries > (int) f->setup_temp_memory_required)
f->setup_temp_memory_required = c->entries;
c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem);
memcpy(c->codeword_lengths, lengths, c->entries);
setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs!
lengths = c->codeword_lengths;
c->sparse = 0;
}
// compute the size of the sorted tables
if (c->sparse) {
sorted_count = total;
} else {
sorted_count = 0;
#ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
for (j=0; j < c->entries; ++j)
if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE)
++sorted_count;
#endif
}
c->sorted_entries = sorted_count;
values = NULL;
CHECK(f);
if (!c->sparse) {
c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries);
if (!c->codewords) return error(f, VORBIS_outofmem);
} else {
unsigned int size;
if (c->sorted_entries) {
c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries);
if (!c->codeword_lengths) return error(f, VORBIS_outofmem);
c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries);
if (!c->codewords) return error(f, VORBIS_outofmem);
values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries);
if (!values) return error(f, VORBIS_outofmem);
}
size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries;
if (size > f->setup_temp_memory_required)
f->setup_temp_memory_required = size;
}
if (!compute_codewords(c, lengths, c->entries, values)) {
if (c->sparse) setup_temp_free(f, values, 0);
return error(f, VORBIS_invalid_setup);
}
if (c->sorted_entries) {
// allocate an extra slot for sentinels
c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1));
if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem);
// allocate an extra slot at the front so that c->sorted_values[-1] is defined
// so that we can catch that case without an extra if
c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1));
if (c->sorted_values == NULL) return error(f, VORBIS_outofmem);
++c->sorted_values;
c->sorted_values[-1] = -1;
compute_sorted_huffman(c, lengths, values);
}
if (c->sparse) {
setup_temp_free(f, values, sizeof(*values)*c->sorted_entries);
setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries);
setup_temp_free(f, lengths, c->entries);
c->codewords = NULL;
}
compute_accelerated_huffman(c);
CHECK(f);
c->lookup_type = get_bits(f, 4);
if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup);
if (c->lookup_type > 0) {
uint16 *mults;
c->minimum_value = float32_unpack(get_bits(f, 32));
c->delta_value = float32_unpack(get_bits(f, 32));
c->value_bits = get_bits(f, 4)+1;
c->sequence_p = get_bits(f,1);
if (c->lookup_type == 1) {
c->lookup_values = lookup1_values(c->entries, c->dimensions);
} else {
c->lookup_values = c->entries * c->dimensions;
}
if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup);
mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values);
if (mults == NULL) return error(f, VORBIS_outofmem);
for (j=0; j < (int) c->lookup_values; ++j) {
int q = get_bits(f, c->value_bits);
if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); }
mults[j] = q;
}
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
int len, sparse = c->sparse;
float last=0;
// pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop
if (sparse) {
if (c->sorted_entries == 0) goto skip;
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions);
} else
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions);
if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); }
len = sparse ? c->sorted_entries : c->entries;
for (j=0; j < len; ++j) {
unsigned int z = sparse ? c->sorted_values[j] : j;
unsigned int div=1;
for (k=0; k < c->dimensions; ++k) {
int off = (z / div) % c->lookup_values;
float val = mults[off];
val = mults[off]*c->delta_value + c->minimum_value + last;
c->multiplicands[j*c->dimensions + k] = val;
if (c->sequence_p)
last = val;
if (k+1 < c->dimensions) {
if (div > UINT_MAX / (unsigned int) c->lookup_values) {
setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values);
return error(f, VORBIS_invalid_setup);
}
div *= c->lookup_values;
}
}
}
c->lookup_type = 2;
}
else
#endif
{
float last=0;
CHECK(f);
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values);
if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); }
for (j=0; j < (int) c->lookup_values; ++j) {
float val = mults[j] * c->delta_value + c->minimum_value + last;
c->multiplicands[j] = val;
if (c->sequence_p)
last = val;
}
}
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
skip:;
#endif
setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values);
CHECK(f);
}
CHECK(f);
}
// time domain transfers (notused)
x = get_bits(f, 6) + 1;
for (i=0; i < x; ++i) {
uint32 z = get_bits(f, 16);
if (z != 0) return error(f, VORBIS_invalid_setup);
}
// Floors
f->floor_count = get_bits(f, 6)+1;
f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config));
if (f->floor_config == NULL) return error(f, VORBIS_outofmem);
for (i=0; i < f->floor_count; ++i) {
f->floor_types[i] = get_bits(f, 16);
if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup);
if (f->floor_types[i] == 0) {
Floor0 *g = &f->floor_config[i].floor0;
g->order = get_bits(f,8);
g->rate = get_bits(f,16);
g->bark_map_size = get_bits(f,16);
g->amplitude_bits = get_bits(f,6);
g->amplitude_offset = get_bits(f,8);
g->number_of_books = get_bits(f,4) + 1;
for (j=0; j < g->number_of_books; ++j)
g->book_list[j] = get_bits(f,8);
return error(f, VORBIS_feature_not_supported);
} else {
stbv__floor_ordering p[31*8+2];
Floor1 *g = &f->floor_config[i].floor1;
int max_class = -1;
g->partitions = get_bits(f, 5);
for (j=0; j < g->partitions; ++j) {
g->partition_class_list[j] = get_bits(f, 4);
if (g->partition_class_list[j] > max_class)
max_class = g->partition_class_list[j];
}
for (j=0; j <= max_class; ++j) {
g->class_dimensions[j] = get_bits(f, 3)+1;
g->class_subclasses[j] = get_bits(f, 2);
if (g->class_subclasses[j]) {
g->class_masterbooks[j] = get_bits(f, 8);
if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
}
for (k=0; k < 1 << g->class_subclasses[j]; ++k) {
g->subclass_books[j][k] = get_bits(f,8)-1;
if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
}
}
g->floor1_multiplier = get_bits(f,2)+1;
g->rangebits = get_bits(f,4);
g->Xlist[0] = 0;
g->Xlist[1] = 1 << g->rangebits;
g->values = 2;
for (j=0; j < g->partitions; ++j) {
int c = g->partition_class_list[j];
for (k=0; k < g->class_dimensions[c]; ++k) {
g->Xlist[g->values] = get_bits(f, g->rangebits);
++g->values;
}
}
// precompute the sorting
for (j=0; j < g->values; ++j) {
p[j].x = g->Xlist[j];
p[j].id = j;
}
qsort(p, g->values, sizeof(p[0]), point_compare);
for (j=0; j < g->values; ++j)
g->sorted_order[j] = (uint8) p[j].id;
// precompute the neighbors
for (j=2; j < g->values; ++j) {
int low,hi;
neighbors(g->Xlist, j, &low,&hi);
g->neighbors[j][0] = low;
g->neighbors[j][1] = hi;
}
if (g->values > longest_floorlist)
longest_floorlist = g->values;
}
}
// Residue
f->residue_count = get_bits(f, 6)+1;
f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0]));
if (f->residue_config == NULL) return error(f, VORBIS_outofmem);
memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0]));
for (i=0; i < f->residue_count; ++i) {
uint8 residue_cascade[64];
Residue *r = f->residue_config+i;
f->residue_types[i] = get_bits(f, 16);
if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup);
r->begin = get_bits(f, 24);
r->end = get_bits(f, 24);
if (r->end < r->begin) return error(f, VORBIS_invalid_setup);
r->part_size = get_bits(f,24)+1;
r->classifications = get_bits(f,6)+1;
r->classbook = get_bits(f,8);
if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup);
for (j=0; j < r->classifications; ++j) {
uint8 high_bits=0;
uint8 low_bits=get_bits(f,3);
if (get_bits(f,1))
high_bits = get_bits(f,5);
residue_cascade[j] = high_bits*8 + low_bits;
}
r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications);
if (r->residue_books == NULL) return error(f, VORBIS_outofmem);
for (j=0; j < r->classifications; ++j) {
for (k=0; k < 8; ++k) {
if (residue_cascade[j] & (1 << k)) {
r->residue_books[j][k] = get_bits(f, 8);
if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
} else {
r->residue_books[j][k] = -1;
}
}
}
// precompute the classifications[] array to avoid inner-loop mod/divide
// call it 'classdata' since we already have r->classifications
r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
if (!r->classdata) return error(f, VORBIS_outofmem);
memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
for (j=0; j < f->codebooks[r->classbook].entries; ++j) {
int classwords = f->codebooks[r->classbook].dimensions;
int temp = j;
r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords);
if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem);
for (k=classwords-1; k >= 0; --k) {
r->classdata[j][k] = temp % r->classifications;
temp /= r->classifications;
}
}
}
f->mapping_count = get_bits(f,6)+1;
f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping));
if (f->mapping == NULL) return error(f, VORBIS_outofmem);
memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping));
for (i=0; i < f->mapping_count; ++i) {
Mapping *m = f->mapping + i;
int mapping_type = get_bits(f,16);
if (mapping_type != 0) return error(f, VORBIS_invalid_setup);
m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan));
if (m->chan == NULL) return error(f, VORBIS_outofmem);
if (get_bits(f,1))
m->submaps = get_bits(f,4)+1;
else
m->submaps = 1;
if (m->submaps > max_submaps)
max_submaps = m->submaps;
if (get_bits(f,1)) {
m->coupling_steps = get_bits(f,8)+1;
for (k=0; k < m->coupling_steps; ++k) {
m->chan[k].magnitude = get_bits(f, ilog(f->channels-1));
m->chan[k].angle = get_bits(f, ilog(f->channels-1));
if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup);
if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup);
if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup);
}
} else
m->coupling_steps = 0;
// reserved field
if (get_bits(f,2)) return error(f, VORBIS_invalid_setup);
if (m->submaps > 1) {
for (j=0; j < f->channels; ++j) {
m->chan[j].mux = get_bits(f, 4);
if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup);
}
} else
// @SPECIFICATION: this case is missing from the spec
for (j=0; j < f->channels; ++j)
m->chan[j].mux = 0;
for (j=0; j < m->submaps; ++j) {
get_bits(f,8); // discard
m->submap_floor[j] = get_bits(f,8);
m->submap_residue[j] = get_bits(f,8);
if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup);
if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup);
}
}
// Modes
f->mode_count = get_bits(f, 6)+1;
for (i=0; i < f->mode_count; ++i) {
Mode *m = f->mode_config+i;
m->blockflag = get_bits(f,1);
m->windowtype = get_bits(f,16);
m->transformtype = get_bits(f,16);
m->mapping = get_bits(f,8);
if (m->windowtype != 0) return error(f, VORBIS_invalid_setup);
if (m->transformtype != 0) return error(f, VORBIS_invalid_setup);
if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup);
}
flush_packet(f);
f->previous_length = 0;
for (i=0; i < f->channels; ++i) {
f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1);
f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2);
f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist);
if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem);
#ifdef STB_VORBIS_NO_DEFER_FLOOR
f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2);
if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem);
#endif
}
if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE;
if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE;
f->blocksize[0] = f->blocksize_0;
f->blocksize[1] = f->blocksize_1;
#ifdef STB_VORBIS_DIVIDE_TABLE
if (integer_divide_table[1][1]==0)
for (i=0; i < DIVTAB_NUMER; ++i)
for (j=1; j < DIVTAB_DENOM; ++j)
integer_divide_table[i][j] = i / j;
#endif
// compute how much temporary memory is needed
// 1.
{
uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1);
uint32 classify_mem;
int i,max_part_read=0;
for (i=0; i < f->residue_count; ++i) {
Residue *r = f->residue_config + i;
int n_read = r->end - r->begin;
int part_read = n_read / r->part_size;
if (part_read > max_part_read)
max_part_read = part_read;
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *));
#else
classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *));
#endif
f->temp_memory_required = classify_mem;
if (imdct_mem > f->temp_memory_required)
f->temp_memory_required = imdct_mem;
}
f->first_decode = TRUE;
if (f->alloc.alloc_buffer) {
assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes);
// check if there's enough temp memory so we don't error later
if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset)
return error(f, VORBIS_outofmem);
}
f->first_audio_page_offset = stb_vorbis_get_file_offset(f);
return TRUE;
}
| 13,598 |
15,103 | 0 | PHP_FUNCTION(imagecopyresampled)
{
zval *SIM, *DIM;
long SX, SY, SW, SH, DX, DY, DW, DH;
gdImagePtr im_dst, im_src;
int srcH, srcW, dstH, dstW, srcY, srcX, dstY, dstX;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrllllllll", &DIM, &SIM, &DX, &DY, &SX, &SY, &DW, &DH, &SW, &SH) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, &DIM, -1, "Image", le_gd);
ZEND_FETCH_RESOURCE(im_src, gdImagePtr, &SIM, -1, "Image", le_gd);
srcX = SX;
srcY = SY;
srcH = SH;
srcW = SW;
dstX = DX;
dstY = DY;
dstH = DH;
dstW = DW;
gdImageCopyResampled(im_dst, im_src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
RETURN_TRUE;
}
| 13,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.