unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
34,927 | 0 | rpc_task_set_rpc_message(struct rpc_task *task, const struct rpc_message *msg)
{
if (msg != NULL) {
task->tk_msg.rpc_proc = msg->rpc_proc;
task->tk_msg.rpc_argp = msg->rpc_argp;
task->tk_msg.rpc_resp = msg->rpc_resp;
if (msg->rpc_cred != NULL)
task->tk_msg.rpc_cred = get_rpccred(msg->rpc_cred);
}
}
| 3,700 |
131,726 | 0 | static void shortAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
TestObjectPythonV8Internal::shortAttributeAttributeSetter(jsValue, info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
| 3,701 |
118,848 | 0 | void WebContentsImpl::DidChooseColorInColorChooser(SkColor color) {
Send(new ViewMsg_DidChooseColorResponse(
GetRoutingID(), color_chooser_identifier_, color));
}
| 3,702 |
40,677 | 0 | SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned int, flags)
{
if (flags & MSG_CMSG_COMPAT)
return -EINVAL;
return __sys_sendmsg(fd, msg, flags);
}
| 3,703 |
185,980 | 1 | v8::Local<v8::Value> V8Debugger::generatorObjectLocation(v8::Local<v8::Object> object)
{
if (!enabled()) {
NOTREACHED();
return v8::Null(m_isolate);
}
v8::Local<v8::Value> argv[] = { object };
v8::Local<v8::Value> location = callDebuggerMethod("getGeneratorObjectLocation", 1, argv).ToLocalChecked();
if (!location->IsObject())
return v8::Null(m_isolate);
v8::Local<v8::Context> context = m_debuggerContext.Get(m_isolate);
if (!markAsInternal(context, v8::Local<v8::Object>::Cast(location), V8InternalValueType::kLocation))
return v8::Null(m_isolate);
return location;
}
| 3,704 |
77,038 | 0 | ovsinst_bitmap_to_openflow(uint32_t ovsinst_bitmap, enum ofp_version version)
{
uint32_t ofpit_bitmap = 0;
const struct ovsinst_map *x;
for (x = get_ovsinst_map(version); x->ofpit >= 0; x++) {
if (ovsinst_bitmap & (1u << x->ovsinst)) {
ofpit_bitmap |= 1u << x->ofpit;
}
}
return htonl(ofpit_bitmap);
}
| 3,705 |
108,213 | 0 | void RunTest(const std::string& test_name, const std::string& test_page) {
OpenDevToolsWindow(test_page);
std::string result;
ASSERT_TRUE(
ui_test_utils::ExecuteJavaScriptAndExtractString(
client_contents_->render_view_host(),
L"",
L"window.domAutomationController.send("
L"'' + (window.uiTests && (typeof uiTests.runTest)));",
&result));
if (result == "function") {
ASSERT_TRUE(
ui_test_utils::ExecuteJavaScriptAndExtractString(
client_contents_->render_view_host(),
L"",
UTF8ToWide(StringPrintf("uiTests.runTest('%s')",
test_name.c_str())),
&result));
EXPECT_EQ("[OK]", result);
} else {
FAIL() << "DevTools front-end is broken.";
}
CloseDevToolsWindow();
}
| 3,706 |
40,540 | 0 | static int netlink_mmap(struct file *file, struct socket *sock,
struct vm_area_struct *vma)
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
struct netlink_ring *ring;
unsigned long start, size, expected;
unsigned int i;
int err = -EINVAL;
if (vma->vm_pgoff)
return -EINVAL;
mutex_lock(&nlk->pg_vec_lock);
expected = 0;
for (ring = &nlk->rx_ring; ring <= &nlk->tx_ring; ring++) {
if (ring->pg_vec == NULL)
continue;
expected += ring->pg_vec_len * ring->pg_vec_pages * PAGE_SIZE;
}
if (expected == 0)
goto out;
size = vma->vm_end - vma->vm_start;
if (size != expected)
goto out;
start = vma->vm_start;
for (ring = &nlk->rx_ring; ring <= &nlk->tx_ring; ring++) {
if (ring->pg_vec == NULL)
continue;
for (i = 0; i < ring->pg_vec_len; i++) {
struct page *page;
void *kaddr = ring->pg_vec[i];
unsigned int pg_num;
for (pg_num = 0; pg_num < ring->pg_vec_pages; pg_num++) {
page = pgvec_to_page(kaddr);
err = vm_insert_page(vma, start, page);
if (err < 0)
goto out;
start += PAGE_SIZE;
kaddr += PAGE_SIZE;
}
}
}
atomic_inc(&nlk->mapped);
vma->vm_ops = &netlink_mmap_ops;
err = 0;
out:
mutex_unlock(&nlk->pg_vec_lock);
return err;
}
| 3,707 |
49,928 | 0 | void php_mysqlnd_auth_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
{
if (!stack_allocation) {
MYSQLND_PACKET_AUTH * p = (MYSQLND_PACKET_AUTH *) _packet;
mnd_pefree(p, p->header.persistent);
}
}
| 3,708 |
9,110 | 0 | void vrend_decode_reset(bool ctx_0_only)
{
int i;
vrend_hw_switch_context(dec_ctx[0]->grctx, true);
if (ctx_0_only == false) {
for (i = 1; i < VREND_MAX_CTX; i++) {
if (!dec_ctx[i])
continue;
if (!dec_ctx[i]->grctx)
continue;
vrend_destroy_context(dec_ctx[i]->grctx);
free(dec_ctx[i]);
dec_ctx[i] = NULL;
}
} else {
vrend_destroy_context(dec_ctx[0]->grctx);
free(dec_ctx[0]);
dec_ctx[0] = NULL;
}
}
| 3,709 |
82,056 | 0 | inspect_main(mrb_state *mrb, mrb_value mod)
{
return mrb_str_new_lit(mrb, "main");
}
| 3,710 |
150,149 | 0 | void VerifyAfterValues(LayerImpl* layer) {
EffectTree& tree = layer->layer_tree_impl()->property_trees()->effect_tree;
EffectNode* node = tree.Node(layer->effect_tree_index());
switch (static_cast<Properties>(index_)) {
case STARTUP:
case DONE:
break;
case BOUNDS:
EXPECT_EQ(gfx::Size(20, 20).ToString(), layer->bounds().ToString());
break;
case HIDE_LAYER_AND_SUBTREE:
EXPECT_EQ(tree.EffectiveOpacity(node), 0.f);
break;
case DRAWS_CONTENT:
EXPECT_TRUE(layer->DrawsContent());
break;
}
}
| 3,711 |
82,997 | 0 | int pdf_add_rectangle(struct pdf_doc *pdf, struct pdf_object *page,
int x, int y, int width, int height, int border_width,
uint32_t colour)
{
int ret;
struct dstr str = {0, 0, 0};
dstr_append(&str, "BT ");
dstr_printf(&str, "%f %f %f RG ",
PDF_RGB_R(colour), PDF_RGB_G(colour), PDF_RGB_B(colour));
dstr_printf(&str, "%d w ", border_width);
dstr_printf(&str, "%d %d %d %d re S ", x, y, width, height);
dstr_append(&str, "ET");
ret = pdf_add_stream(pdf, page, str.data);
dstr_free(&str);
return ret;
}
| 3,712 |
114,850 | 0 | void TestingAutomationProvider::AutofillAcceptSelection(
Browser* browser,
DictionaryValue* args,
IPC::Message* reply_message) {
int tab_index;
if (!args->GetInteger("tab_index", &tab_index)) {
AutomationJSONReply(this, reply_message).SendError(
"Invalid or missing args");
return;
}
WebContents* web_contents = browser->GetWebContentsAt(tab_index);
if (!web_contents) {
AutomationJSONReply(this, reply_message).SendError(
StringPrintf("No such tab at index %d", tab_index));
return;
}
new AutofillDisplayedObserver(
chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA,
web_contents->GetRenderViewHost(), this, reply_message);
SendWebKeyPressEventAsync(ui::VKEY_RETURN, web_contents);
}
| 3,713 |
144,527 | 0 | WebContentsImpl::GetJavaWebContents() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return GetWebContentsAndroid()->GetJavaObject();
}
| 3,714 |
48,897 | 0 | static void netdev_sync_lower_features(struct net_device *upper,
struct net_device *lower, netdev_features_t features)
{
netdev_features_t upper_disables = NETIF_F_UPPER_DISABLES;
netdev_features_t feature;
int feature_bit;
for_each_netdev_feature(&upper_disables, feature_bit) {
feature = __NETIF_F_BIT(feature_bit);
if (!(features & feature) && (lower->features & feature)) {
netdev_dbg(upper, "Disabling feature %pNF on lower dev %s.\n",
&feature, lower->name);
lower->wanted_features &= ~feature;
netdev_update_features(lower);
if (unlikely(lower->features & feature))
netdev_WARN(upper, "failed to disable %pNF on %s!\n",
&feature, lower->name);
}
}
}
| 3,715 |
107,915 | 0 | AccessibilityTypes::Role InfoBarContainer::GetAccessibleRole() {
return AccessibilityTypes::ROLE_GROUPING;
}
| 3,716 |
92,533 | 0 | static void detach_task(struct task_struct *p, struct lb_env *env)
{
lockdep_assert_held(&env->src_rq->lock);
p->on_rq = TASK_ON_RQ_MIGRATING;
deactivate_task(env->src_rq, p, DEQUEUE_NOCLOCK);
set_task_cpu(p, env->dst_cpu);
}
| 3,717 |
76,668 | 0 | static void t1_subset_charstrings(void)
{
cs_entry *ptr;
/* at this point t1_line_array contains "/CharStrings".
when we hit a case like this:
dup/CharStrings
229 dict dup begin
we read the next line and concatenate to t1_line_array before moving on
*/
t1_check_unusual_charstring();
cs_size_pos = strstr(t1_line_array, charstringname)
+ strlen(charstringname) - t1_line_array + 1;
/* cs_size_pos points to the number indicating
dict size after "/CharStrings" */
cs_size = t1_scan_num(t1_line_array + cs_size_pos, 0);
cs_ptr = cs_tab = xtalloc(cs_size, cs_entry);
for (ptr = cs_tab; ptr - cs_tab < cs_size; ptr++)
init_cs_entry(ptr);
cs_notdef = NULL;
cs_dict_start = xstrdup(t1_line_array);
t1_getline();
while (t1_cslen) {
store_cs();
t1_getline();
}
cs_dict_end = xstrdup(t1_line_array);
t1_mark_glyphs();
if (subr_tab != NULL) {
if (cs_token_pair == NULL)
pdftex_fail
("This Type 1 font uses mismatched subroutine begin/end token pairs.");
t1_subr_flush();
}
for (cs_count = 0, ptr = cs_tab; ptr < cs_ptr; ptr++)
if (ptr->used)
cs_count++;
t1_cs_flush();
}
| 3,718 |
65,062 | 0 | static const char *func_id_name(int id)
{
BUILD_BUG_ON(ARRAY_SIZE(func_id_str) != __BPF_FUNC_MAX_ID);
if (id >= 0 && id < __BPF_FUNC_MAX_ID && func_id_str[id])
return func_id_str[id];
else
return "unknown";
}
| 3,719 |
15,686 | 0 | static void pxa2xx_clkcfg_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
PXA2xxState *s = (PXA2xxState *)ri->opaque;
s->clkcfg = value & 0xf;
if (value & 2) {
printf("%s: CPU frequency change attempt\n", __func__);
}
}
| 3,720 |
124,097 | 0 | std::string ChromeContentBrowserClient::GetDefaultDownloadName() {
return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME);
}
| 3,721 |
118,884 | 0 | base::TerminationStatus WebContentsImpl::GetCrashedStatus() const {
return crashed_status_;
}
| 3,722 |
174,264 | 0 | void Camera3Device::RequestThread::setErrorState(const char *fmt, ...) {
sp<Camera3Device> parent = mParent.promote();
if (parent != NULL) {
va_list args;
va_start(args, fmt);
parent->setErrorStateV(fmt, args);
va_end(args);
}
}
| 3,723 |
157,788 | 0 | int WebContentsImpl::GetTopControlsHeight() const {
return delegate_ ? delegate_->GetTopControlsHeight() : 0;
}
| 3,724 |
101,262 | 0 | Id Get(int64 metahandle, syncable::IdField field) const {
return GetField(metahandle, field, syncable::GetNullId());
}
| 3,725 |
170,461 | 0 | status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const
{
int32_t useAshmem;
status_t status = readInt32(&useAshmem);
if (status) return status;
if (!useAshmem) {
ALOGV("readBlob: read in place");
const void* ptr = readInplace(len);
if (!ptr) return BAD_VALUE;
outBlob->init(false /*mapped*/, const_cast<void*>(ptr), len);
return NO_ERROR;
}
ALOGV("readBlob: read from ashmem");
int fd = readFileDescriptor();
if (fd == int(BAD_TYPE)) return BAD_VALUE;
void* ptr = ::mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED) return NO_MEMORY;
outBlob->init(true /*mapped*/, ptr, len);
return NO_ERROR;
}
| 3,726 |
56,420 | 0 | http_GetHdr(const struct http *hp, const char *hdr, char **ptr)
{
unsigned u, l;
char *p;
l = hdr[0];
diagnostic(l == strlen(hdr + 1));
assert(hdr[l] == ':');
hdr++;
u = http_findhdr(hp, l - 1, hdr);
if (u == 0) {
if (ptr != NULL)
*ptr = NULL;
return (0);
}
if (ptr != NULL) {
p = hp->hd[u].b + l;
while (vct_issp(*p))
p++;
*ptr = p;
}
return (1);
}
| 3,727 |
40,054 | 0 | EncodeDateOnly(struct tm * tm, int style, char *str, bool EuroDates)
{
if (tm->tm_mon < 1 || tm->tm_mon > MONTHS_PER_YEAR)
return -1;
switch (style)
{
case USE_ISO_DATES:
/* compatible with ISO date formats */
if (tm->tm_year > 0)
sprintf(str, "%04d-%02d-%02d",
tm->tm_year, tm->tm_mon, tm->tm_mday);
else
sprintf(str, "%04d-%02d-%02d %s",
-(tm->tm_year - 1), tm->tm_mon, tm->tm_mday, "BC");
break;
case USE_SQL_DATES:
/* compatible with Oracle/Ingres date formats */
if (EuroDates)
sprintf(str, "%02d/%02d", tm->tm_mday, tm->tm_mon);
else
sprintf(str, "%02d/%02d", tm->tm_mon, tm->tm_mday);
if (tm->tm_year > 0)
sprintf(str + 5, "/%04d", tm->tm_year);
else
sprintf(str + 5, "/%04d %s", -(tm->tm_year - 1), "BC");
break;
case USE_GERMAN_DATES:
/* German-style date format */
sprintf(str, "%02d.%02d", tm->tm_mday, tm->tm_mon);
if (tm->tm_year > 0)
sprintf(str + 5, ".%04d", tm->tm_year);
else
sprintf(str + 5, ".%04d %s", -(tm->tm_year - 1), "BC");
break;
case USE_POSTGRES_DATES:
default:
/* traditional date-only style for Postgres */
if (EuroDates)
sprintf(str, "%02d-%02d", tm->tm_mday, tm->tm_mon);
else
sprintf(str, "%02d-%02d", tm->tm_mon, tm->tm_mday);
if (tm->tm_year > 0)
sprintf(str + 5, "-%04d", tm->tm_year);
else
sprintf(str + 5, "-%04d %s", -(tm->tm_year - 1), "BC");
break;
}
return TRUE;
} /* EncodeDateOnly() */
| 3,728 |
155,285 | 0 | bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
const GURL& url,
content::ResourceContext* context,
const std::vector<content::GlobalFrameRoutingId>& render_frames) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
content_settings::CookieSettings* cookie_settings =
io_data->GetCookieSettings();
bool allow = cookie_settings->IsCookieAccessAllowed(url, url);
for (const auto& it : render_frames) {
base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&TabSpecificContentSettings::IndexedDBAccessed,
it.child_id, it.frame_routing_id, url, !allow));
}
return allow;
}
| 3,729 |
53,242 | 0 | static int proc_submiturb_compat(struct usb_dev_state *ps, void __user *arg)
{
struct usbdevfs_urb uurb;
if (get_urb32(&uurb, (struct usbdevfs_urb32 __user *)arg))
return -EFAULT;
return proc_do_submiturb(ps, &uurb,
((struct usbdevfs_urb32 __user *)arg)->iso_frame_desc,
arg);
}
| 3,730 |
95,624 | 0 | void Field_Clear( field_t *edit ) {
memset( edit->buffer, 0, MAX_EDIT_LINE );
edit->cursor = 0;
edit->scroll = 0;
}
| 3,731 |
23,860 | 0 | struct socket *tun_get_socket(struct file *file)
{
struct tun_struct *tun;
if (file->f_op != &tun_fops)
return ERR_PTR(-EINVAL);
tun = tun_get(file);
if (!tun)
return ERR_PTR(-EBADFD);
tun_put(tun);
return &tun->socket;
}
| 3,732 |
97,516 | 0 | CachePolicy FrameLoader::subresourceCachePolicy() const
{
if (m_isComplete)
return CachePolicyVerify;
if (m_loadType == FrameLoadTypeReloadFromOrigin)
return CachePolicyReload;
if (Frame* parentFrame = m_frame->tree()->parent()) {
CachePolicy parentCachePolicy = parentFrame->loader()->subresourceCachePolicy();
if (parentCachePolicy != CachePolicyVerify)
return parentCachePolicy;
}
const ResourceRequest& request(documentLoader()->request());
if (request.cachePolicy() == ReloadIgnoringCacheData && !equalIgnoringCase(request.httpMethod(), "post"))
return CachePolicyRevalidate;
if (m_loadType == FrameLoadTypeReload)
return CachePolicyRevalidate;
return CachePolicyVerify;
}
| 3,733 |
164,146 | 0 | void ScheduleUserCallback(int result) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(&MockResponseReader::InvokeUserCompletionCallback,
weak_factory_.GetWeakPtr(), result));
}
| 3,734 |
111,416 | 0 | void WebPage::updateDisabledPluginFiles(const BlackBerry::Platform::String& fileName, bool disabled)
{
PluginDatabase* database = PluginDatabase::installedPlugins(true /* true for loading default directories */);
if (!database)
return;
if (disabled) {
if (!database->addDisabledPluginFile(fileName))
return;
} else {
if (!database->removeDisabledPluginFile(fileName))
return;
}
d->m_page->refreshPlugins(false /* false for minimum disruption as described above */);
if (d->m_webSettings->arePluginsEnabled())
database->refresh();
}
| 3,735 |
72,016 | 0 | static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
const PrimitiveInfo *primitive_info)
{
typedef struct _LineSegment
{
double
p,
q;
} LineSegment;
double
delta_theta,
dot_product,
mid,
miterlimit;
LineSegment
dx,
dy,
inverse_slope,
slope,
theta;
MagickBooleanType
closed_path;
PointInfo
box_p[5],
box_q[5],
center,
offset,
*path_p,
*path_q;
PrimitiveInfo
*polygon_primitive,
*stroke_polygon;
register ssize_t
i;
size_t
arc_segments,
max_strokes,
number_vertices;
ssize_t
j,
n,
p,
q;
/*
Allocate paths.
*/
number_vertices=primitive_info->coordinates;
max_strokes=2*number_vertices+6*BezierQuantum+360;
path_p=(PointInfo *) AcquireQuantumMemory((size_t) max_strokes,
sizeof(*path_p));
path_q=(PointInfo *) AcquireQuantumMemory((size_t) max_strokes,
sizeof(*path_q));
polygon_primitive=(PrimitiveInfo *) AcquireQuantumMemory((size_t)
number_vertices+2UL,sizeof(*polygon_primitive));
if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL) ||
(polygon_primitive == (PrimitiveInfo *) NULL))
return((PrimitiveInfo *) NULL);
(void) CopyMagickMemory(polygon_primitive,primitive_info,(size_t)
number_vertices*sizeof(*polygon_primitive));
closed_path=
(fabs(primitive_info[number_vertices-1].point.x-primitive_info[0].point.x) < DrawEpsilon) &&
(fabs(primitive_info[number_vertices-1].point.y-primitive_info[0].point.y) < DrawEpsilon) ?
MagickTrue : MagickFalse;
if ((draw_info->linejoin == RoundJoin) ||
((draw_info->linejoin == MiterJoin) && (closed_path != MagickFalse)))
{
polygon_primitive[number_vertices]=primitive_info[1];
number_vertices++;
}
polygon_primitive[number_vertices].primitive=UndefinedPrimitive;
/*
Compute the slope for the first line segment, p.
*/
dx.p=0.0;
dy.p=0.0;
for (n=1; n < (ssize_t) number_vertices; n++)
{
dx.p=polygon_primitive[n].point.x-polygon_primitive[0].point.x;
dy.p=polygon_primitive[n].point.y-polygon_primitive[0].point.y;
if ((fabs(dx.p) >= DrawEpsilon) || (fabs(dy.p) >= DrawEpsilon))
break;
}
if (n == (ssize_t) number_vertices)
n=(ssize_t) number_vertices-1L;
slope.p=0.0;
inverse_slope.p=0.0;
if (fabs(dx.p) < DrawEpsilon)
{
if (dx.p >= 0.0)
slope.p=dy.p < 0.0 ? -1.0/DrawEpsilon : 1.0/DrawEpsilon;
else
slope.p=dy.p < 0.0 ? 1.0/DrawEpsilon : -1.0/DrawEpsilon;
}
else
if (fabs(dy.p) < DrawEpsilon)
{
if (dy.p >= 0.0)
inverse_slope.p=dx.p < 0.0 ? -1.0/DrawEpsilon : 1.0/DrawEpsilon;
else
inverse_slope.p=dx.p < 0.0 ? 1.0/DrawEpsilon : -1.0/DrawEpsilon;
}
else
{
slope.p=dy.p/dx.p;
inverse_slope.p=(-1.0/slope.p);
}
mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
miterlimit=(double) (draw_info->miterlimit*draw_info->miterlimit*mid*mid);
if ((draw_info->linecap == SquareCap) && (closed_path == MagickFalse))
TraceSquareLinecap(polygon_primitive,number_vertices,mid);
offset.x=sqrt((double) (mid*mid/(inverse_slope.p*inverse_slope.p+1.0)));
offset.y=(double) (offset.x*inverse_slope.p);
if ((dy.p*offset.x-dx.p*offset.y) > 0.0)
{
box_p[0].x=polygon_primitive[0].point.x-offset.x;
box_p[0].y=polygon_primitive[0].point.y-offset.x*inverse_slope.p;
box_p[1].x=polygon_primitive[n].point.x-offset.x;
box_p[1].y=polygon_primitive[n].point.y-offset.x*inverse_slope.p;
box_q[0].x=polygon_primitive[0].point.x+offset.x;
box_q[0].y=polygon_primitive[0].point.y+offset.x*inverse_slope.p;
box_q[1].x=polygon_primitive[n].point.x+offset.x;
box_q[1].y=polygon_primitive[n].point.y+offset.x*inverse_slope.p;
}
else
{
box_p[0].x=polygon_primitive[0].point.x+offset.x;
box_p[0].y=polygon_primitive[0].point.y+offset.y;
box_p[1].x=polygon_primitive[n].point.x+offset.x;
box_p[1].y=polygon_primitive[n].point.y+offset.y;
box_q[0].x=polygon_primitive[0].point.x-offset.x;
box_q[0].y=polygon_primitive[0].point.y-offset.y;
box_q[1].x=polygon_primitive[n].point.x-offset.x;
box_q[1].y=polygon_primitive[n].point.y-offset.y;
}
/*
Create strokes for the line join attribute: bevel, miter, round.
*/
p=0;
q=0;
path_q[p++]=box_q[0];
path_p[q++]=box_p[0];
for (i=(ssize_t) n+1; i < (ssize_t) number_vertices; i++)
{
/*
Compute the slope for this line segment, q.
*/
dx.q=polygon_primitive[i].point.x-polygon_primitive[n].point.x;
dy.q=polygon_primitive[i].point.y-polygon_primitive[n].point.y;
dot_product=dx.q*dx.q+dy.q*dy.q;
if (dot_product < 0.25)
continue;
slope.q=0.0;
inverse_slope.q=0.0;
if (fabs(dx.q) < DrawEpsilon)
{
if (dx.q >= 0.0)
slope.q=dy.q < 0.0 ? -1.0/DrawEpsilon : 1.0/DrawEpsilon;
else
slope.q=dy.q < 0.0 ? 1.0/DrawEpsilon : -1.0/DrawEpsilon;
}
else
if (fabs(dy.q) < DrawEpsilon)
{
if (dy.q >= 0.0)
inverse_slope.q=dx.q < 0.0 ? -1.0/DrawEpsilon : 1.0/DrawEpsilon;
else
inverse_slope.q=dx.q < 0.0 ? 1.0/DrawEpsilon : -1.0/DrawEpsilon;
}
else
{
slope.q=dy.q/dx.q;
inverse_slope.q=(-1.0/slope.q);
}
offset.x=sqrt((double) (mid*mid/(inverse_slope.q*inverse_slope.q+1.0)));
offset.y=(double) (offset.x*inverse_slope.q);
dot_product=dy.q*offset.x-dx.q*offset.y;
if (dot_product > 0.0)
{
box_p[2].x=polygon_primitive[n].point.x-offset.x;
box_p[2].y=polygon_primitive[n].point.y-offset.y;
box_p[3].x=polygon_primitive[i].point.x-offset.x;
box_p[3].y=polygon_primitive[i].point.y-offset.y;
box_q[2].x=polygon_primitive[n].point.x+offset.x;
box_q[2].y=polygon_primitive[n].point.y+offset.y;
box_q[3].x=polygon_primitive[i].point.x+offset.x;
box_q[3].y=polygon_primitive[i].point.y+offset.y;
}
else
{
box_p[2].x=polygon_primitive[n].point.x+offset.x;
box_p[2].y=polygon_primitive[n].point.y+offset.y;
box_p[3].x=polygon_primitive[i].point.x+offset.x;
box_p[3].y=polygon_primitive[i].point.y+offset.y;
box_q[2].x=polygon_primitive[n].point.x-offset.x;
box_q[2].y=polygon_primitive[n].point.y-offset.y;
box_q[3].x=polygon_primitive[i].point.x-offset.x;
box_q[3].y=polygon_primitive[i].point.y-offset.y;
}
if (fabs((double) (slope.p-slope.q)) < DrawEpsilon)
{
box_p[4]=box_p[1];
box_q[4]=box_q[1];
}
else
{
box_p[4].x=(double) ((slope.p*box_p[0].x-box_p[0].y-slope.q*box_p[3].x+
box_p[3].y)/(slope.p-slope.q));
box_p[4].y=(double) (slope.p*(box_p[4].x-box_p[0].x)+box_p[0].y);
box_q[4].x=(double) ((slope.p*box_q[0].x-box_q[0].y-slope.q*box_q[3].x+
box_q[3].y)/(slope.p-slope.q));
box_q[4].y=(double) (slope.p*(box_q[4].x-box_q[0].x)+box_q[0].y);
}
if (q >= (ssize_t) (max_strokes-6*BezierQuantum-360))
{
if (~max_strokes < (6*BezierQuantum+360))
{
path_p=(PointInfo *) RelinquishMagickMemory(path_p);
path_q=(PointInfo *) RelinquishMagickMemory(path_q);
}
else
{
max_strokes+=6*BezierQuantum+360;
path_p=(PointInfo *) ResizeQuantumMemory(path_p,max_strokes,
sizeof(*path_p));
path_q=(PointInfo *) ResizeQuantumMemory(path_q,max_strokes,
sizeof(*path_q));
}
if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL))
{
if (path_p != (PointInfo *) NULL)
path_p=(PointInfo *) RelinquishMagickMemory(path_p);
if (path_q != (PointInfo *) NULL)
path_q=(PointInfo *) RelinquishMagickMemory(path_q);
polygon_primitive=(PrimitiveInfo *)
RelinquishMagickMemory(polygon_primitive);
return((PrimitiveInfo *) NULL);
}
}
dot_product=dx.q*dy.p-dx.p*dy.q;
if (dot_product <= 0.0)
switch (draw_info->linejoin)
{
case BevelJoin:
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
path_p[p++]=box_p[4];
else
{
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
}
break;
}
case MiterJoin:
{
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
{
path_q[q++]=box_q[4];
path_p[p++]=box_p[4];
}
else
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
}
break;
}
case RoundJoin:
{
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
path_p[p++]=box_p[4];
else
{
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
}
center=polygon_primitive[n].point;
theta.p=atan2(box_q[1].y-center.y,box_q[1].x-center.x);
theta.q=atan2(box_q[2].y-center.y,box_q[2].x-center.x);
if (theta.q < theta.p)
theta.q+=2.0*MagickPI;
arc_segments=(size_t) ceil((double) ((theta.q-theta.p)/
(2.0*sqrt((double) (1.0/mid)))));
path_q[q].x=box_q[1].x;
path_q[q].y=box_q[1].y;
q++;
for (j=1; j < (ssize_t) arc_segments; j++)
{
delta_theta=(double) (j*(theta.q-theta.p)/arc_segments);
path_q[q].x=(double) (center.x+mid*cos(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
path_q[q].y=(double) (center.y+mid*sin(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
q++;
}
path_q[q++]=box_q[2];
break;
}
default:
break;
}
else
switch (draw_info->linejoin)
{
case BevelJoin:
{
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
path_q[q++]=box_q[4];
else
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
}
break;
}
case MiterJoin:
{
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
{
path_q[q++]=box_q[4];
path_p[p++]=box_p[4];
}
else
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
path_p[p++]=box_p[1];
path_p[p++]=box_p[2];
}
break;
}
case RoundJoin:
{
dot_product=(box_q[4].x-box_p[4].x)*(box_q[4].x-box_p[4].x)+
(box_q[4].y-box_p[4].y)*(box_q[4].y-box_p[4].y);
if (dot_product <= miterlimit)
path_q[q++]=box_q[4];
else
{
path_q[q++]=box_q[1];
path_q[q++]=box_q[2];
}
center=polygon_primitive[n].point;
theta.p=atan2(box_p[1].y-center.y,box_p[1].x-center.x);
theta.q=atan2(box_p[2].y-center.y,box_p[2].x-center.x);
if (theta.p < theta.q)
theta.p+=2.0*MagickPI;
arc_segments=(size_t) ceil((double) ((theta.p-theta.q)/
(2.0*sqrt((double) (1.0/mid)))));
path_p[p++]=box_p[1];
for (j=1; j < (ssize_t) arc_segments; j++)
{
delta_theta=(double) (j*(theta.q-theta.p)/arc_segments);
path_p[p].x=(double) (center.x+mid*cos(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
path_p[p].y=(double) (center.y+mid*sin(fmod((double)
(theta.p+delta_theta),DegreesToRadians(360.0))));
p++;
}
path_p[p++]=box_p[2];
break;
}
default:
break;
}
slope.p=slope.q;
inverse_slope.p=inverse_slope.q;
box_p[0]=box_p[2];
box_p[1]=box_p[3];
box_q[0]=box_q[2];
box_q[1]=box_q[3];
dx.p=dx.q;
dy.p=dy.q;
n=i;
}
path_p[p++]=box_p[1];
path_q[q++]=box_q[1];
/*
Trace stroked polygon.
*/
stroke_polygon=(PrimitiveInfo *) AcquireQuantumMemory((size_t)
(p+q+2UL*closed_path+2UL),sizeof(*stroke_polygon));
if (stroke_polygon != (PrimitiveInfo *) NULL)
{
for (i=0; i < (ssize_t) p; i++)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=path_p[i];
}
if (closed_path != MagickFalse)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=stroke_polygon[0].point;
i++;
}
for ( ; i < (ssize_t) (p+q+closed_path); i++)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=path_q[p+q+closed_path-(i+1)];
}
if (closed_path != MagickFalse)
{
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=stroke_polygon[p+closed_path].point;
i++;
}
stroke_polygon[i]=polygon_primitive[0];
stroke_polygon[i].point=stroke_polygon[0].point;
i++;
stroke_polygon[i].primitive=UndefinedPrimitive;
stroke_polygon[0].coordinates=(size_t) (p+q+2*closed_path+1);
}
path_p=(PointInfo *) RelinquishMagickMemory(path_p);
path_q=(PointInfo *) RelinquishMagickMemory(path_q);
polygon_primitive=(PrimitiveInfo *) RelinquishMagickMemory(polygon_primitive);
return(stroke_polygon);
}
| 3,736 |
130,090 | 0 | void PopulatePolicyHandlerParameters(PolicyHandlerParameters* parameters) {
#if defined(OS_CHROMEOS)
if (user_manager::UserManager::IsInitialized()) {
const user_manager::User* user =
user_manager::UserManager::Get()->GetActiveUser();
if (user)
parameters->user_id_hash = user->username_hash();
}
#endif
}
| 3,737 |
89,829 | 0 | static int processPCPRequest(void * req, int req_size, pcp_info_t *pcp_msg_info)
{
int remainingSize;
/* start with PCP_SUCCESS as result code,
* if everything is OK value will be unchanged */
pcp_msg_info->result_code = PCP_SUCCESS;
remainingSize = req_size;
/* discard request that exceeds maximal length,
or that is shorter than PCP_MIN_LEN (=24)
or that is not the multiple of 4 */
if (req_size < 3)
return 0; /* ignore msg */
if (req_size < PCP_MIN_LEN) {
pcp_msg_info->result_code = PCP_ERR_MALFORMED_REQUEST;
return 1; /* send response */
}
if ( (req_size > PCP_MAX_LEN) || ( (req_size & 3) != 0)) {
syslog(LOG_ERR, "PCP: Size of PCP packet(%d) is larger than %d bytes or "
"the size is not multiple of 4.\n", req_size, PCP_MAX_LEN);
pcp_msg_info->result_code = PCP_ERR_MALFORMED_REQUEST;
return 1; /* send response */
}
/* first parse request header */
if (parseCommonRequestHeader(req, pcp_msg_info) ) {
return 1;
}
remainingSize -= PCP_COMMON_REQUEST_SIZE;
req += PCP_COMMON_REQUEST_SIZE;
if (pcp_msg_info->version == 1) {
/* legacy PCP version 1 support */
switch (pcp_msg_info->opcode) {
case PCP_OPCODE_MAP:
remainingSize -= PCP_MAP_V1_SIZE;
if (remainingSize < 0) {
pcp_msg_info->result_code = PCP_ERR_MALFORMED_REQUEST;
return pcp_msg_info->result_code;
}
#ifdef DEBUG
printMAPOpcodeVersion1(req);
#endif /* DEBUG */
parsePCPMAP_version1(req, pcp_msg_info);
req += PCP_MAP_V1_SIZE;
parsePCPOptions(req, remainingSize, pcp_msg_info);
if (ValidatePCPMsg(pcp_msg_info)) {
if (pcp_msg_info->lifetime == 0) {
DeletePCPMap(pcp_msg_info);
} else {
CreatePCPMap(pcp_msg_info);
}
} else {
syslog(LOG_ERR, "PCP: Invalid PCP v1 MAP message.");
return pcp_msg_info->result_code;
}
break;
#ifdef PCP_PEER
case PCP_OPCODE_PEER:
remainingSize -= PCP_PEER_V1_SIZE;
if (remainingSize < 0) {
pcp_msg_info->result_code = PCP_ERR_MALFORMED_REQUEST;
return pcp_msg_info->result_code;
}
#ifdef DEBUG
printPEEROpcodeVersion1(req);
#endif /* DEBUG */
parsePCPPEER_version1(req, pcp_msg_info);
req += PCP_PEER_V1_SIZE;
parsePCPOptions(req, remainingSize, pcp_msg_info);
if (ValidatePCPMsg(pcp_msg_info)) {
if (pcp_msg_info->lifetime == 0) {
DeletePCPPeer(pcp_msg_info);
} else {
CreatePCPPeer(pcp_msg_info);
}
} else {
syslog(LOG_ERR, "PCP: Invalid PCP v1 PEER message.");
return pcp_msg_info->result_code;
}
break;
#endif /* PCP_PEER */
default:
pcp_msg_info->result_code = PCP_ERR_UNSUPP_OPCODE;
break;
}
} else if (pcp_msg_info->version == 2) {
/* RFC 6887 PCP support
* http://tools.ietf.org/html/rfc6887 */
switch (pcp_msg_info->opcode) {
case PCP_OPCODE_ANNOUNCE:
/* should check PCP Client's IP Address in request */
/* see http://tools.ietf.org/html/rfc6887#section-14.1 */
break;
case PCP_OPCODE_MAP:
remainingSize -= PCP_MAP_V2_SIZE;
if (remainingSize < 0) {
pcp_msg_info->result_code = PCP_ERR_MALFORMED_REQUEST;
return pcp_msg_info->result_code;
}
#ifdef DEBUG
printMAPOpcodeVersion2(req);
#endif /* DEBUG */
parsePCPMAP_version2(req, pcp_msg_info);
req += PCP_MAP_V2_SIZE;
parsePCPOptions(req, remainingSize, pcp_msg_info);
if (ValidatePCPMsg(pcp_msg_info)) {
if (pcp_msg_info->lifetime == 0) {
DeletePCPMap(pcp_msg_info);
} else {
CreatePCPMap(pcp_msg_info);
}
} else {
syslog(LOG_ERR, "PCP: Invalid PCP v2 MAP message.");
return pcp_msg_info->result_code;
}
break;
#ifdef PCP_PEER
case PCP_OPCODE_PEER:
remainingSize -= PCP_PEER_V2_SIZE;
if (remainingSize < 0) {
pcp_msg_info->result_code = PCP_ERR_MALFORMED_REQUEST;
return pcp_msg_info->result_code;
}
#ifdef DEBUG
printPEEROpcodeVersion2(req);
#endif /* DEBUG */
parsePCPPEER_version2(req, pcp_msg_info);
req += PCP_PEER_V2_SIZE;
if (pcp_msg_info->result_code != 0) {
return pcp_msg_info->result_code;
}
parsePCPOptions(req, remainingSize, pcp_msg_info);
if (ValidatePCPMsg(pcp_msg_info)) {
if (pcp_msg_info->lifetime == 0) {
DeletePCPPeer(pcp_msg_info);
} else {
CreatePCPPeer(pcp_msg_info);
}
} else {
syslog(LOG_ERR, "PCP: Invalid PCP v2 PEER message.");
}
break;
#endif /* PCP_PEER */
#ifdef PCP_SADSCP
case PCP_OPCODE_SADSCP:
remainingSize -= PCP_SADSCP_REQ_SIZE;
if (remainingSize < 0) {
pcp_msg_info->result_code = PCP_ERR_MALFORMED_REQUEST;
return pcp_msg_info->result_code;
}
remainingSize -= ((uint8_t *)req)[13]; /* app_name_length */
if (remainingSize < 0) {
pcp_msg_info->result_code = PCP_ERR_MALFORMED_OPTION;
return pcp_msg_info->result_code;
}
#ifdef DEBUG
printSADSCPOpcode(req);
#endif
parseSADSCP(req, pcp_msg_info);
req += PCP_SADSCP_REQ_SIZE;
if (pcp_msg_info->result_code != 0) {
return pcp_msg_info->result_code;
}
req += pcp_msg_info->app_name_len;
get_dscp_value(pcp_msg_info);
break;
#endif
default:
pcp_msg_info->result_code = PCP_ERR_UNSUPP_OPCODE;
break;
}
} else {
pcp_msg_info->result_code = PCP_ERR_UNSUPP_VERSION;
return pcp_msg_info->result_code;
}
return 1;
}
| 3,738 |
157,872 | 0 | void WebContentsImpl::ShowCreatedWidget(int process_id,
int widget_route_id,
const gfx::Rect& initial_rect) {
ShowCreatedWidget(process_id, widget_route_id, false, initial_rect);
}
| 3,739 |
118,934 | 0 | double WebContentsImpl::GetZoomLevel() const {
HostZoomMapImpl* zoom_map = static_cast<HostZoomMapImpl*>(
HostZoomMap::GetForBrowserContext(GetBrowserContext()));
if (!zoom_map)
return 0;
double zoom_level;
if (temporary_zoom_settings_) {
zoom_level = zoom_map->GetTemporaryZoomLevel(
GetRenderProcessHost()->GetID(), GetRenderViewHost()->GetRoutingID());
} else {
GURL url;
NavigationEntry* active_entry = GetController().GetActiveEntry();
url = active_entry ? active_entry->GetURL() : GURL::EmptyGURL();
zoom_level = zoom_map->GetZoomLevelForHostAndScheme(url.scheme(),
net::GetHostOrSpecFromURL(url));
}
return zoom_level;
}
| 3,740 |
182,911 | 1 | vips_malloc( VipsObject *object, size_t size )
{
void *buf;
buf = g_malloc( size );
if( object ) {
g_signal_connect( object, "postclose",
G_CALLBACK( vips_malloc_cb ), buf );
object->local_memory += size;
}
return( buf );
}
| 3,741 |
32,052 | 0 | int __dev_addr_add(struct dev_addr_list **list, int *count,
void *addr, int alen, int glbl)
{
struct dev_addr_list *da;
for (da = *list; da != NULL; da = da->next) {
if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 &&
da->da_addrlen == alen) {
if (glbl) {
int old_glbl = da->da_gusers;
da->da_gusers = 1;
if (old_glbl)
return 0;
}
da->da_users++;
return 0;
}
}
da = kzalloc(sizeof(*da), GFP_ATOMIC);
if (da == NULL)
return -ENOMEM;
memcpy(da->da_addr, addr, alen);
da->da_addrlen = alen;
da->da_users = 1;
da->da_gusers = glbl ? 1 : 0;
da->next = *list;
*list = da;
(*count)++;
return 0;
}
| 3,742 |
58,784 | 0 | int fastcall __lock_page_killable(struct page *page)
{
DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
return __wait_on_bit_lock(page_waitqueue(page), &wait,
sync_page_killable, TASK_KILLABLE);
}
| 3,743 |
121,592 | 0 | static size_t findPlainText(CharacterIterator& it, const String& target, FindOptions options, size_t& matchStart)
{
matchStart = 0;
size_t matchLength = 0;
SearchBuffer buffer(target, options);
if (buffer.needsMoreContext()) {
RefPtr<Range> startRange = it.range();
RefPtr<Range> beforeStartRange = startRange->ownerDocument()->createRange();
beforeStartRange->setEnd(startRange->startContainer(), startRange->startOffset(), IGNORE_EXCEPTION);
for (SimplifiedBackwardsTextIterator backwardsIterator(beforeStartRange.get()); !backwardsIterator.atEnd(); backwardsIterator.advance()) {
buffer.prependContext(backwardsIterator.characters(), backwardsIterator.length());
if (!buffer.needsMoreContext())
break;
}
}
while (!it.atEnd()) {
it.advance(buffer.append(it.characters(), it.length()));
tryAgain:
size_t matchStartOffset;
if (size_t newMatchLength = buffer.search(matchStartOffset)) {
size_t lastCharacterInBufferOffset = it.characterOffset();
ASSERT(lastCharacterInBufferOffset >= matchStartOffset);
matchStart = lastCharacterInBufferOffset - matchStartOffset;
matchLength = newMatchLength;
if (!(options & Backwards))
break;
goto tryAgain;
}
if (it.atBreak() && !buffer.atBreak()) {
buffer.reachedBreak();
goto tryAgain;
}
}
return matchLength;
}
| 3,744 |
128,470 | 0 | std::unique_ptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue()
const {
std::unique_ptr<base::trace_event::TracedValue> value(
new base::trace_event::TracedValue());
value->SetString("title", base::UTF16ToUTF8(title_));
value->SetString("application_id", application_id_);
return value;
}
| 3,745 |
29,583 | 0 | static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
loff_t *new_pos)
{
struct kern_ipc_perm *ipc;
int total, id;
total = 0;
for (id = 0; id < pos && total < ids->in_use; id++) {
ipc = idr_find(&ids->ipcs_idr, id);
if (ipc != NULL)
total++;
}
if (total >= ids->in_use)
return NULL;
for ( ; pos < IPCMNI; pos++) {
ipc = idr_find(&ids->ipcs_idr, pos);
if (ipc != NULL) {
*new_pos = pos + 1;
ipc_lock_by_ptr(ipc);
return ipc;
}
}
/* Out of range - return NULL to terminate iteration */
return NULL;
}
| 3,746 |
99,305 | 0 | void ResourceMessageFilter::OnGetFileModificationTime(const FilePath& path,
IPC::Message* reply_msg) {
if (!ChildProcessSecurityPolicy::GetInstance()->CanUploadFile(id(), path)) {
ViewHostMsg_GetFileModificationTime::WriteReplyParams(reply_msg,
base::Time());
Send(reply_msg);
return;
}
ChromeThread::PostTask(
ChromeThread::FILE, FROM_HERE,
NewRunnableMethod(
this, &ResourceMessageFilter::OnGetFileInfoOnFileThread,
path, reply_msg, &WriteFileModificationTime));
}
| 3,747 |
119,963 | 0 | bool IsRelativeURL(const char* base,
const url_parse::Parsed& base_parsed,
const char* fragment,
int fragment_len,
bool is_base_hierarchical,
bool* is_relative,
url_parse::Component* relative_component) {
return DoIsRelativeURL<char>(
base, base_parsed, fragment, fragment_len, is_base_hierarchical,
is_relative, relative_component);
}
| 3,748 |
85,612 | 0 | static void hns_rcb_ring_get_cfg(struct hnae_queue *q, int ring_type)
{
struct hnae_ring *ring;
struct rcb_common_cb *rcb_common;
struct ring_pair_cb *ring_pair_cb;
u16 desc_num, mdnum_ppkt;
bool irq_idx, is_ver1;
ring_pair_cb = container_of(q, struct ring_pair_cb, q);
is_ver1 = AE_IS_VER1(ring_pair_cb->rcb_common->dsaf_dev->dsaf_ver);
if (ring_type == RX_RING) {
ring = &q->rx_ring;
ring->io_base = ring_pair_cb->q.io_base;
irq_idx = HNS_RCB_IRQ_IDX_RX;
mdnum_ppkt = HNS_RCB_RING_MAX_BD_PER_PKT;
} else {
ring = &q->tx_ring;
ring->io_base = (u8 __iomem *)ring_pair_cb->q.io_base +
HNS_RCB_TX_REG_OFFSET;
irq_idx = HNS_RCB_IRQ_IDX_TX;
mdnum_ppkt = is_ver1 ? HNS_RCB_RING_MAX_TXBD_PER_PKT :
HNS_RCBV2_RING_MAX_TXBD_PER_PKT;
}
rcb_common = ring_pair_cb->rcb_common;
desc_num = rcb_common->dsaf_dev->desc_num;
ring->desc = NULL;
ring->desc_cb = NULL;
ring->irq = ring_pair_cb->virq[irq_idx];
ring->desc_dma_addr = 0;
ring->buf_size = RCB_DEFAULT_BUFFER_SIZE;
ring->desc_num = desc_num;
ring->max_desc_num_per_pkt = mdnum_ppkt;
ring->max_raw_data_sz_per_desc = HNS_RCB_MAX_PKT_SIZE;
ring->max_pkt_size = HNS_RCB_MAX_PKT_SIZE;
ring->next_to_use = 0;
ring->next_to_clean = 0;
}
| 3,749 |
3,365 | 0 | zstatus(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
switch (r_type(op)) {
case t_file:
{
stream *s;
make_bool(op, (file_is_valid(s, op) ? 1 : 0));
}
return 0;
case t_string:
{
gs_parsed_file_name_t pname;
struct stat fstat;
int code = parse_file_name(op, &pname,
i_ctx_p->LockFilePermissions, imemory);
if (code < 0) {
if (code == gs_error_undefinedfilename) {
make_bool(op, 0);
code = 0;
}
return code;
}
code = gs_terminate_file_name(&pname, imemory, "status");
if (code < 0)
return code;
if ((code = check_file_permissions(i_ctx_p, pname.fname, pname.len,
pname.iodev, "PermitFileReading")) >= 0) {
code = (*pname.iodev->procs.file_status)(pname.iodev,
pname.fname, &fstat);
}
switch (code) {
case 0:
check_ostack(4);
/*
* Check to make sure that the file size fits into
* a PostScript integer. (On some systems, long is
* 32 bits, but file sizes are 64 bits.)
*/
push(4);
make_int(op - 4, stat_blocks(&fstat));
make_int(op - 3, fstat.st_size);
/*
* We can't check the value simply by using ==,
* because signed/unsigned == does the wrong thing.
* Instead, since integer assignment only keeps the
* bottom bits, we convert the values to double
* and then test for equality. This handles all
* cases of signed/unsigned or width mismatch.
*/
if ((double)op[-4].value.intval !=
(double)stat_blocks(&fstat) ||
(double)op[-3].value.intval !=
(double)fstat.st_size
)
return_error(gs_error_limitcheck);
make_int(op - 2, fstat.st_mtime);
make_int(op - 1, fstat.st_ctime);
make_bool(op, 1);
break;
case gs_error_undefinedfilename:
make_bool(op, 0);
code = 0;
}
gs_free_file_name(&pname, "status");
return code;
}
default:
return_op_typecheck(op);
}
}
| 3,750 |
81,265 | 0 | static void create_trace_options_dir(struct trace_array *tr)
{
struct dentry *t_options;
bool top_level = tr == &global_trace;
int i;
t_options = trace_options_init_dentry(tr);
if (!t_options)
return;
for (i = 0; trace_options[i]; i++) {
if (top_level ||
!((1 << i) & TOP_LEVEL_TRACE_FLAGS))
create_trace_option_core_file(tr, trace_options[i], i);
}
}
| 3,751 |
152,772 | 0 | bool SparseHistogram::HasConstructionArguments(
Sample expected_minimum,
Sample expected_maximum,
uint32_t expected_bucket_count) const {
return false;
}
| 3,752 |
103,829 | 0 | void RenderView::OnSelectAll() {
if (!webview())
return;
webview()->focusedFrame()->executeCommand(
WebString::fromUTF8("SelectAll"));
}
| 3,753 |
87,993 | 0 | static void do_pf_read(void)
{
ps_set_intr(do_pf_read_start, NULL, 0, nice);
}
| 3,754 |
129,858 | 0 | static bool IsAllKeyValueInDict(const JsonKeyValue* key_values,
DictionaryValue* dict) {
while (key_values && key_values->key) {
if (!IsKeyValueInDict(key_values, dict))
return false;
++key_values;
}
return true;
}
| 3,755 |
131,599 | 0 | static void perWorldBindingsVoidMethodMethodCallbackForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
TestObjectPythonV8Internal::perWorldBindingsVoidMethodMethodForMainWorld(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
| 3,756 |
175,228 | 0 | int orderly_poweroff(bool force)
{
int argc;
char **argv = argv_split(GFP_ATOMIC, poweroff_cmd, &argc);
static char *envp[] = {
"HOME=/",
"PATH=/sbin:/bin:/usr/sbin:/usr/bin",
NULL
};
int ret = -ENOMEM;
struct subprocess_info *info;
if (argv == NULL) {
printk(KERN_WARNING "%s failed to allocate memory for \"%s\"\n",
__func__, poweroff_cmd);
goto out;
}
info = call_usermodehelper_setup(argv[0], argv, envp, GFP_ATOMIC);
if (info == NULL) {
argv_free(argv);
goto out;
}
call_usermodehelper_setfns(info, NULL, argv_cleanup, NULL);
ret = call_usermodehelper_exec(info, UMH_NO_WAIT);
out:
if (ret && force) {
printk(KERN_WARNING "Failed to start orderly shutdown: "
"forcing the issue\n");
/* I guess this should try to kick off some daemon to
sync and poweroff asap. Or not even bother syncing
if we're doing an emergency shutdown? */
emergency_sync();
kernel_power_off();
}
return ret;
}
| 3,757 |
176,681 | 0 | xmlPopInput(xmlParserCtxtPtr ctxt) {
if ((ctxt == NULL) || (ctxt->inputNr <= 1)) return(0);
if (xmlParserDebugEntities)
xmlGenericError(xmlGenericErrorContext,
"Popping input %d\n", ctxt->inputNr);
xmlFreeInputStream(inputPop(ctxt));
if ((*ctxt->input->cur == 0) &&
(xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
return(xmlPopInput(ctxt));
return(CUR);
}
| 3,758 |
24,139 | 0 | aptcTimerHandler(unsigned long arg)
{
u32 numbytes;
u32 throughput;
struct ar6_softc *ar;
int status;
ar = (struct ar6_softc *)arg;
A_ASSERT(ar != NULL);
A_ASSERT(!timer_pending(&aptcTimer));
AR6000_SPIN_LOCK(&ar->arLock, 0);
/* Get the number of bytes transferred */
numbytes = aptcTR.bytesTransmitted + aptcTR.bytesReceived;
aptcTR.bytesTransmitted = aptcTR.bytesReceived = 0;
/* Calculate and decide based on throughput thresholds */
throughput = ((numbytes * 8)/APTC_TRAFFIC_SAMPLING_INTERVAL); /* Kbps */
if (throughput < APTC_LOWER_THROUGHPUT_THRESHOLD) {
/* Enable Sleep and delete the timer */
A_ASSERT(ar->arWmiReady == true);
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
status = wmi_powermode_cmd(ar->arWmi, REC_POWER);
AR6000_SPIN_LOCK(&ar->arLock, 0);
A_ASSERT(status == 0);
aptcTR.timerScheduled = false;
} else {
A_TIMEOUT_MS(&aptcTimer, APTC_TRAFFIC_SAMPLING_INTERVAL, 0);
}
AR6000_SPIN_UNLOCK(&ar->arLock, 0);
}
| 3,759 |
56,992 | 0 | static void sctp_cmd_assoc_change(sctp_cmd_seq_t *commands,
struct sctp_association *asoc,
u8 state)
{
struct sctp_ulpevent *ev;
ev = sctp_ulpevent_make_assoc_change(asoc, 0, state, 0,
asoc->c.sinit_num_ostreams,
asoc->c.sinit_max_instreams,
NULL, GFP_ATOMIC);
if (ev)
sctp_ulpq_tail_event(&asoc->ulpq, ev);
}
| 3,760 |
115,670 | 0 | bool ClientSession::ShouldIgnoreRemoteMouseInput(
const protocol::MouseEvent& event) const {
if (remote_mouse_button_state_ != 0)
return false;
if (awaiting_continue_approval_)
return true;
int64 millis = (base::Time::Now() - latest_local_input_time_)
.InMilliseconds();
if (millis < kRemoteBlockTimeoutMillis)
return true;
return false;
}
| 3,761 |
32,811 | 0 | static int tigon3_dma_hwbug_workaround(struct tg3_napi *tnapi,
struct sk_buff **pskb,
u32 *entry, u32 *budget,
u32 base_flags, u32 mss, u32 vlan)
{
struct tg3 *tp = tnapi->tp;
struct sk_buff *new_skb, *skb = *pskb;
dma_addr_t new_addr = 0;
int ret = 0;
if (tg3_asic_rev(tp) != ASIC_REV_5701)
new_skb = skb_copy(skb, GFP_ATOMIC);
else {
int more_headroom = 4 - ((unsigned long)skb->data & 3);
new_skb = skb_copy_expand(skb,
skb_headroom(skb) + more_headroom,
skb_tailroom(skb), GFP_ATOMIC);
}
if (!new_skb) {
ret = -1;
} else {
/* New SKB is guaranteed to be linear. */
new_addr = pci_map_single(tp->pdev, new_skb->data, new_skb->len,
PCI_DMA_TODEVICE);
/* Make sure the mapping succeeded */
if (pci_dma_mapping_error(tp->pdev, new_addr)) {
dev_kfree_skb(new_skb);
ret = -1;
} else {
u32 save_entry = *entry;
base_flags |= TXD_FLAG_END;
tnapi->tx_buffers[*entry].skb = new_skb;
dma_unmap_addr_set(&tnapi->tx_buffers[*entry],
mapping, new_addr);
if (tg3_tx_frag_set(tnapi, entry, budget, new_addr,
new_skb->len, base_flags,
mss, vlan)) {
tg3_tx_skb_unmap(tnapi, save_entry, -1);
dev_kfree_skb(new_skb);
ret = -1;
}
}
}
dev_kfree_skb(skb);
*pskb = new_skb;
return ret;
}
| 3,762 |
27,619 | 0 | int sequencer_open(int dev, struct file *file)
{
int retval, mode, i;
int level, tmp;
if (!sequencer_ok)
sequencer_init();
level = ((dev & 0x0f) == SND_DEV_SEQ2) ? 2 : 1;
dev = dev >> 4;
mode = translate_mode(file);
DEB(printk("sequencer_open(dev=%d)\n", dev));
if (!sequencer_ok)
{
/* printk("Sound card: sequencer not initialized\n");*/
return -ENXIO;
}
if (dev) /* Patch manager device (obsolete) */
return -ENXIO;
if(synth_devs[dev] == NULL)
request_module("synth0");
if (mode == OPEN_READ)
{
if (!num_midis)
{
/*printk("Sequencer: No MIDI devices. Input not possible\n");*/
sequencer_busy = 0;
return -ENXIO;
}
}
if (sequencer_busy)
{
return -EBUSY;
}
sequencer_busy = 1;
obsolete_api_used = 0;
max_mididev = num_midis;
max_synthdev = num_synths;
pre_event_timeout = MAX_SCHEDULE_TIMEOUT;
seq_mode = SEQ_1;
if (pending_timer != -1)
{
tmr_no = pending_timer;
pending_timer = -1;
}
if (tmr_no == -1) /* Not selected yet */
{
int i, best;
best = -1;
for (i = 0; i < num_sound_timers; i++)
if (sound_timer_devs[i] && sound_timer_devs[i]->priority > best)
{
tmr_no = i;
best = sound_timer_devs[i]->priority;
}
if (tmr_no == -1) /* Should not be */
tmr_no = 0;
}
tmr = sound_timer_devs[tmr_no];
if (level == 2)
{
if (tmr == NULL)
{
/*printk("sequencer: No timer for level 2\n");*/
sequencer_busy = 0;
return -ENXIO;
}
setup_mode2();
}
if (!max_synthdev && !max_mididev)
{
sequencer_busy=0;
return -ENXIO;
}
synth_open_mask = 0;
for (i = 0; i < max_mididev; i++)
{
midi_opened[i] = 0;
midi_written[i] = 0;
}
for (i = 0; i < max_synthdev; i++)
{
if (synth_devs[i]==NULL)
continue;
if (!try_module_get(synth_devs[i]->owner))
continue;
if ((tmp = synth_devs[i]->open(i, mode)) < 0)
{
printk(KERN_WARNING "Sequencer: Warning! Cannot open synth device #%d (%d)\n", i, tmp);
if (synth_devs[i]->midi_dev)
printk(KERN_WARNING "(Maps to MIDI dev #%d)\n", synth_devs[i]->midi_dev);
}
else
{
synth_open_mask |= (1 << i);
if (synth_devs[i]->midi_dev)
midi_opened[synth_devs[i]->midi_dev] = 1;
}
}
seq_time = jiffies;
prev_input_time = 0;
prev_event_time = 0;
if (seq_mode == SEQ_1 && (mode == OPEN_READ || mode == OPEN_READWRITE))
{
/*
* Initialize midi input devices
*/
for (i = 0; i < max_mididev; i++)
if (!midi_opened[i] && midi_devs[i])
{
if (!try_module_get(midi_devs[i]->owner))
continue;
if ((retval = midi_devs[i]->open(i, mode,
sequencer_midi_input, sequencer_midi_output)) >= 0)
{
midi_opened[i] = 1;
}
}
}
if (seq_mode == SEQ_2) {
if (try_module_get(tmr->owner))
tmr->open(tmr_no, seq_mode);
}
init_waitqueue_head(&seq_sleeper);
init_waitqueue_head(&midi_sleeper);
output_threshold = SEQ_MAX_QUEUE / 2;
return 0;
}
| 3,763 |
164,091 | 0 | bool AppCacheDatabase::CreateSchema() {
sql::Transaction transaction(db_.get());
if (!transaction.Begin())
return false;
if (!meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion))
return false;
if (!meta_table_->SetValue(kExperimentFlagsKey,
GetActiveExperimentFlags())) {
return false;
}
for (int i = 0; i < kTableCount; ++i) {
if (!CreateTable(db_.get(), kTables[i]))
return false;
}
for (int i = 0; i < kIndexCount; ++i) {
if (!CreateIndex(db_.get(), kIndexes[i]))
return false;
}
return transaction.Commit();
}
| 3,764 |
149,424 | 0 | void ContentSecurityPolicy::applyPolicySideEffectsToExecutionContext() {
DCHECK(m_executionContext &&
m_executionContext->securityContext().getSecurityOrigin());
setupSelf(*m_executionContext->securityContext().getSecurityOrigin());
if (Document* document = this->document()) {
if (m_sandboxMask != SandboxNone) {
UseCounter::count(document, UseCounter::SandboxViaCSP);
document->enforceSandboxFlags(m_sandboxMask);
}
if (m_treatAsPublicAddress)
document->setAddressSpace(WebAddressSpacePublic);
document->enforceInsecureRequestPolicy(m_insecureRequestPolicy);
if (m_insecureRequestPolicy & kUpgradeInsecureRequests) {
UseCounter::count(document, UseCounter::UpgradeInsecureRequestsEnabled);
if (!document->url().host().isEmpty())
document->addInsecureNavigationUpgrade(
document->url().host().impl()->hash());
}
for (const auto& consoleMessage : m_consoleMessages)
m_executionContext->addConsoleMessage(consoleMessage);
m_consoleMessages.clear();
for (const auto& policy : m_policies) {
UseCounter::count(*document, getUseCounterType(policy->headerType()));
if (policy->allowDynamic())
UseCounter::count(*document, UseCounter::CSPWithStrictDynamic);
}
}
if (!m_disableEvalErrorMessage.isNull())
m_executionContext->disableEval(m_disableEvalErrorMessage);
}
| 3,765 |
57,766 | 0 | static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
struct kvm_interrupt *irq)
{
if (irq->irq >= KVM_NR_INTERRUPTS)
return -EINVAL;
if (!irqchip_in_kernel(vcpu->kvm)) {
kvm_queue_interrupt(vcpu, irq->irq, false);
kvm_make_request(KVM_REQ_EVENT, vcpu);
return 0;
}
/*
* With in-kernel LAPIC, we only use this to inject EXTINT, so
* fail for in-kernel 8259.
*/
if (pic_in_kernel(vcpu->kvm))
return -ENXIO;
if (vcpu->arch.pending_external_vector != -1)
return -EEXIST;
vcpu->arch.pending_external_vector = irq->irq;
kvm_make_request(KVM_REQ_EVENT, vcpu);
return 0;
}
| 3,766 |
68,675 | 0 | message_send_invite(const char *const roomjid, const char *const contact,
const char *const reason)
{
xmpp_ctx_t * const ctx = connection_get_ctx();
xmpp_stanza_t *stanza;
muc_member_type_t member_type = muc_member_type(roomjid);
if (member_type == MUC_MEMBER_TYPE_PUBLIC) {
log_debug("Sending direct invite to %s, for %s", contact, roomjid);
char *password = muc_password(roomjid);
stanza = stanza_create_invite(ctx, roomjid, contact, reason, password);
} else {
log_debug("Sending mediated invite to %s, for %s", contact, roomjid);
stanza = stanza_create_mediated_invite(ctx, roomjid, contact, reason);
}
_send_message_stanza(stanza);
xmpp_stanza_release(stanza);
}
| 3,767 |
169,465 | 0 | void NetworkChangeNotifierMac::SetDynamicStoreNotificationKeys(
SCDynamicStoreRef store) {
#if defined(OS_IOS)
NOTREACHED();
#else
base::ScopedCFTypeRef<CFMutableArrayRef> notification_keys(
CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
base::ScopedCFTypeRef<CFStringRef> key(
SCDynamicStoreKeyCreateNetworkGlobalEntity(
NULL, kSCDynamicStoreDomainState, kSCEntNetInterface));
CFArrayAppendValue(notification_keys.get(), key.get());
key.reset(SCDynamicStoreKeyCreateNetworkGlobalEntity(
NULL, kSCDynamicStoreDomainState, kSCEntNetIPv4));
CFArrayAppendValue(notification_keys.get(), key.get());
key.reset(SCDynamicStoreKeyCreateNetworkGlobalEntity(
NULL, kSCDynamicStoreDomainState, kSCEntNetIPv6));
CFArrayAppendValue(notification_keys.get(), key.get());
bool ret = SCDynamicStoreSetNotificationKeys(
store, notification_keys.get(), NULL);
CHECK(ret);
#endif // defined(OS_IOS)
}
| 3,768 |
104,454 | 0 | GLvoid StubGLGetShaderiv(GLuint shader, GLenum pname, GLint* params) {
glGetShaderiv(shader, pname, params);
}
| 3,769 |
167,719 | 0 | void WebRuntimeFeatures::EnableLazyImageLoading(bool enable) {
RuntimeEnabledFeatures::SetLazyImageLoadingEnabled(enable);
}
| 3,770 |
90,554 | 0 | detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
struct vm_area_struct *prev, unsigned long end)
{
struct vm_area_struct **insertion_point;
struct vm_area_struct *tail_vma = NULL;
insertion_point = (prev ? &prev->vm_next : &mm->mmap);
vma->vm_prev = NULL;
do {
vma_rb_erase(vma, &mm->mm_rb);
mm->map_count--;
tail_vma = vma;
vma = vma->vm_next;
} while (vma && vma->vm_start < end);
*insertion_point = vma;
if (vma) {
vma->vm_prev = prev;
vma_gap_update(vma);
} else
mm->highest_vm_end = prev ? vm_end_gap(prev) : 0;
tail_vma->vm_next = NULL;
/* Kill the cache */
vmacache_invalidate(mm);
}
| 3,771 |
116,273 | 0 | void QQuickWebView::mouseMoveEvent(QMouseEvent* event)
{
Q_D(QQuickWebView);
d->handleMouseEvent(event);
}
| 3,772 |
45,537 | 0 | static void authenc_esn_request_complete(struct aead_request *req, int err)
{
if (err != -EINPROGRESS)
aead_request_complete(req, err);
}
| 3,773 |
49,549 | 0 | static int xc2028_get_afc(struct dvb_frontend *fe, s32 *afc)
{
struct xc2028_data *priv = fe->tuner_priv;
int i, rc;
u16 frq_lock = 0;
s16 afc_reg = 0;
rc = check_device_status(priv);
if (rc < 0)
return rc;
/* If the device is sleeping, no channel is tuned */
if (!rc) {
*afc = 0;
return 0;
}
mutex_lock(&priv->lock);
/* Sync Lock Indicator */
for (i = 0; i < 3; i++) {
rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock);
if (rc < 0)
goto ret;
if (frq_lock)
break;
msleep(6);
}
/* Frequency didn't lock */
if (frq_lock == 2)
goto ret;
/* Get AFC */
rc = xc2028_get_reg(priv, XREG_FREQ_ERROR, &afc_reg);
if (rc < 0)
goto ret;
*afc = afc_reg * 15625; /* Hz */
tuner_dbg("AFC is %d Hz\n", *afc);
ret:
mutex_unlock(&priv->lock);
return rc;
}
| 3,774 |
36,952 | 0 | command_send_data (Fep *fep,
FepControlMessage *request)
{
ssize_t total = 0;
while (total < request->args[0].len)
{
ssize_t bytes_sent = _fep_output_send_data (fep,
request->args[0].str + total,
request->args[0].len - total);
if (bytes_sent < 0)
break;
total += bytes_sent;
}
}
| 3,775 |
53,219 | 0 | static int proc_control_compat(struct usb_dev_state *ps,
struct usbdevfs_ctrltransfer32 __user *p32)
{
struct usbdevfs_ctrltransfer __user *p;
__u32 udata;
p = compat_alloc_user_space(sizeof(*p));
if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) ||
get_user(udata, &p32->data) ||
put_user(compat_ptr(udata), &p->data))
return -EFAULT;
return proc_control(ps, p);
}
| 3,776 |
83,553 | 0 | static void update_flush(rdpContext* context)
{
rdpUpdate* update = context->update;
if (update->numberOrders > 0)
{
update->EndPaint(context);
update->BeginPaint(context);
}
}
| 3,777 |
165,463 | 0 | void Document::UpdateStyleAndLayoutIgnorePendingStylesheets(
Document::RunPostLayoutTasks run_post_layout_tasks) {
LocalFrameView* local_view = View();
if (local_view)
local_view->WillStartForcedLayout();
if (!RuntimeEnabledFeatures::CSSInBodyDoesNotBlockPaintEnabled())
UpdateStyleAndLayoutTreeIgnorePendingStylesheets();
UpdateStyleAndLayout();
if (local_view) {
if (run_post_layout_tasks == kRunPostLayoutTasksSynchronously)
local_view->FlushAnyPendingPostLayoutTasks();
local_view->DidFinishForcedLayout();
}
}
| 3,778 |
73,471 | 0 | MagickExport MagickBooleanType GetOneVirtualMethodPixel(const Image *image,
const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
PixelPacket *pixel,ExceptionInfo *exception)
{
CacheInfo
*magick_restrict cache_info;
const int
id = GetOpenMPThreadId();
const PixelPacket
*magick_restrict pixels;
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
assert(image->cache != (Cache) NULL);
cache_info=(CacheInfo *) image->cache;
assert(cache_info->signature == MagickSignature);
*pixel=image->background_color;
if (cache_info->methods.get_one_virtual_pixel_from_handler !=
(GetOneVirtualPixelFromHandler) NULL)
return(cache_info->methods.get_one_virtual_pixel_from_handler(image,
virtual_pixel_method,x,y,pixel,exception));
assert(id < (int) cache_info->number_threads);
pixels=GetVirtualPixelsFromNexus(image,virtual_pixel_method,x,y,1UL,1UL,
cache_info->nexus_info[id],exception);
if (pixels == (const PixelPacket *) NULL)
return(MagickFalse);
*pixel=(*pixels);
return(MagickTrue);
}
| 3,779 |
171,943 | 0 | static void bta_pan_callback_transfer(UINT16 event, char *p_param)
{
tBTA_PAN *p_data = (tBTA_PAN *)p_param;
switch(event)
{
case BTA_PAN_ENABLE_EVT:
BTIF_TRACE_DEBUG("BTA_PAN_ENABLE_EVT");
break;
case BTA_PAN_SET_ROLE_EVT:
{
int btpan_role = bta_role_to_btpan(p_data->set_role.role);
bt_status_t status = p_data->set_role.status == BTA_PAN_SUCCESS ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
btpan_control_state_t state = btpan_role == 0 ? BTPAN_STATE_DISABLED : BTPAN_STATE_ENABLED;
callback.control_state_cb(state, btpan_role, status, TAP_IF_NAME);
break;
}
case BTA_PAN_OPENING_EVT:
{
btpan_conn_t* conn;
bdstr_t bds;
bdaddr_to_string((bt_bdaddr_t *)p_data->opening.bd_addr, bds, sizeof(bds));
BTIF_TRACE_DEBUG("BTA_PAN_OPENING_EVT handle %d, addr: %s", p_data->opening.handle, bds);
conn = btpan_find_conn_addr(p_data->opening.bd_addr);
asrt(conn != NULL);
if (conn)
{
conn->handle = p_data->opening.handle;
int btpan_conn_local_role = bta_role_to_btpan(conn->local_role);
int btpan_remote_role = bta_role_to_btpan(conn->remote_role);
callback.connection_state_cb(BTPAN_STATE_CONNECTING, BT_STATUS_SUCCESS,
(const bt_bdaddr_t*)p_data->opening.bd_addr, btpan_conn_local_role, btpan_remote_role);
}
else
BTIF_TRACE_ERROR("connection not found");
break;
}
case BTA_PAN_OPEN_EVT:
{
btpan_connection_state_t state;
bt_status_t status;
btpan_conn_t *conn = btpan_find_conn_handle(p_data->open.handle);
LOG_VERBOSE("%s pan connection open status: %d", __func__, p_data->open.status);
if (p_data->open.status == BTA_PAN_SUCCESS)
{
state = BTPAN_STATE_CONNECTED;
status = BT_STATUS_SUCCESS;
btpan_open_conn(conn, p_data);
}
else
{
state = BTPAN_STATE_DISCONNECTED;
status = BT_STATUS_FAIL;
btpan_cleanup_conn(conn);
}
/* debug("BTA_PAN_OPEN_EVT handle:%d, conn:%p", p_data->open.handle, conn); */
/* debug("conn bta local_role:%d, bta remote role:%d", conn->local_role, conn->remote_role); */
int btpan_conn_local_role = bta_role_to_btpan(p_data->open.local_role);
int btpan_remote_role = bta_role_to_btpan(p_data->open.peer_role);
callback.connection_state_cb(state, status, (const bt_bdaddr_t*)p_data->open.bd_addr,
btpan_conn_local_role, btpan_remote_role);
break;
}
case BTA_PAN_CLOSE_EVT:
{
btpan_conn_t* conn = btpan_find_conn_handle(p_data->close.handle);
LOG_INFO("%s: event = BTA_PAN_CLOSE_EVT handle %d", __FUNCTION__, p_data->close.handle);
btpan_close_conn(conn);
if (conn && conn->handle >= 0)
{
int btpan_conn_local_role = bta_role_to_btpan(conn->local_role);
int btpan_remote_role = bta_role_to_btpan(conn->remote_role);
callback.connection_state_cb(BTPAN_STATE_DISCONNECTED, 0, (const bt_bdaddr_t*)conn->peer,
btpan_conn_local_role, btpan_remote_role);
btpan_cleanup_conn(conn);
}
else
BTIF_TRACE_ERROR("pan handle not found (%d)", p_data->close.handle);
break;
}
default:
BTIF_TRACE_WARNING("Unknown pan event %d", event);
break;
}
}
| 3,780 |
22,734 | 0 | void sock_release(struct socket *sock)
{
if (sock->ops) {
struct module *owner = sock->ops->owner;
sock->ops->release(sock);
sock->ops = NULL;
module_put(owner);
}
if (rcu_dereference_protected(sock->wq, 1)->fasync_list)
printk(KERN_ERR "sock_release: fasync list not empty!\n");
percpu_sub(sockets_in_use, 1);
if (!sock->file) {
iput(SOCK_INODE(sock));
return;
}
sock->file = NULL;
}
| 3,781 |
128,438 | 0 | IntRect RenderLayerScrollableArea::scrollCornerRect() const
{
bool hasHorizontalBar = horizontalScrollbar();
bool hasVerticalBar = verticalScrollbar();
bool hasResizer = box().style()->resize() != RESIZE_NONE;
if ((hasHorizontalBar && hasVerticalBar) || (hasResizer && (hasHorizontalBar || hasVerticalBar)))
return cornerRect(box().style(), horizontalScrollbar(), verticalScrollbar(), box().pixelSnappedBorderBoxRect());
return IntRect();
}
| 3,782 |
152,047 | 0 | void RenderFrameHostImpl::OnSetNeedsOcclusionTracking(bool needs_tracking) {
RenderFrameProxyHost* proxy =
frame_tree_node()->render_manager()->GetProxyToParent();
if (!proxy) {
bad_message::ReceivedBadMessage(GetProcess(),
bad_message::RFH_NO_PROXY_TO_PARENT);
return;
}
proxy->Send(new FrameMsg_SetNeedsOcclusionTracking(proxy->GetRoutingID(),
needs_tracking));
}
| 3,783 |
84,123 | 0 | void blkcg_deactivate_policy(struct request_queue *q,
const struct blkcg_policy *pol)
{
struct blkcg_gq *blkg;
if (!blkcg_policy_enabled(q, pol))
return;
if (q->mq_ops)
blk_mq_freeze_queue(q);
else
blk_queue_bypass_start(q);
spin_lock_irq(q->queue_lock);
__clear_bit(pol->plid, q->blkcg_pols);
list_for_each_entry(blkg, &q->blkg_list, q_node) {
/* grab blkcg lock too while removing @pd from @blkg */
spin_lock(&blkg->blkcg->lock);
if (blkg->pd[pol->plid]) {
if (pol->pd_offline_fn)
pol->pd_offline_fn(blkg->pd[pol->plid]);
pol->pd_free_fn(blkg->pd[pol->plid]);
blkg->pd[pol->plid] = NULL;
}
spin_unlock(&blkg->blkcg->lock);
}
spin_unlock_irq(q->queue_lock);
if (q->mq_ops)
blk_mq_unfreeze_queue(q);
else
blk_queue_bypass_end(q);
}
| 3,784 |
31,111 | 0 | static int dcbnl_pgtx_setcfg(struct net_device *netdev, struct nlmsghdr *nlh,
u32 seq, struct nlattr **tb, struct sk_buff *skb)
{
return __dcbnl_pg_setcfg(netdev, nlh, seq, tb, skb, 0);
}
| 3,785 |
57,413 | 0 | static void trusted_destroy(struct key *key)
{
struct trusted_key_payload *p = key->payload.data[0];
if (!p)
return;
memset(p->key, 0, p->key_len);
kfree(key->payload.data[0]);
}
| 3,786 |
44,318 | 0 | static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh)
{
struct net *net = sock_net(in_skb->sk);
struct rtmsg *rtm;
struct nlattr *tb[RTA_MAX+1];
struct rtable *rt = NULL;
struct flowi4 fl4;
__be32 dst = 0;
__be32 src = 0;
u32 iif;
int err;
int mark;
struct sk_buff *skb;
err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv4_policy);
if (err < 0)
goto errout;
rtm = nlmsg_data(nlh);
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
if (skb == NULL) {
err = -ENOBUFS;
goto errout;
}
/* Reserve room for dummy headers, this skb can pass
through good chunk of routing engine.
*/
skb_reset_mac_header(skb);
skb_reset_network_header(skb);
/* Bugfix: need to give ip_route_input enough of an IP header to not gag. */
ip_hdr(skb)->protocol = IPPROTO_ICMP;
skb_reserve(skb, MAX_HEADER + sizeof(struct iphdr));
src = tb[RTA_SRC] ? nla_get_be32(tb[RTA_SRC]) : 0;
dst = tb[RTA_DST] ? nla_get_be32(tb[RTA_DST]) : 0;
iif = tb[RTA_IIF] ? nla_get_u32(tb[RTA_IIF]) : 0;
mark = tb[RTA_MARK] ? nla_get_u32(tb[RTA_MARK]) : 0;
memset(&fl4, 0, sizeof(fl4));
fl4.daddr = dst;
fl4.saddr = src;
fl4.flowi4_tos = rtm->rtm_tos;
fl4.flowi4_oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0;
fl4.flowi4_mark = mark;
if (iif) {
struct net_device *dev;
dev = __dev_get_by_index(net, iif);
if (dev == NULL) {
err = -ENODEV;
goto errout_free;
}
skb->protocol = htons(ETH_P_IP);
skb->dev = dev;
skb->mark = mark;
local_bh_disable();
err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev);
local_bh_enable();
rt = skb_rtable(skb);
if (err == 0 && rt->dst.error)
err = -rt->dst.error;
} else {
rt = ip_route_output_key(net, &fl4);
err = 0;
if (IS_ERR(rt))
err = PTR_ERR(rt);
}
if (err)
goto errout_free;
skb_dst_set(skb, &rt->dst);
if (rtm->rtm_flags & RTM_F_NOTIFY)
rt->rt_flags |= RTCF_NOTIFY;
err = rt_fill_info(net, dst, src, &fl4, skb,
NETLINK_CB(in_skb).portid, nlh->nlmsg_seq,
RTM_NEWROUTE, 0, 0);
if (err <= 0)
goto errout_free;
err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).portid);
errout:
return err;
errout_free:
kfree_skb(skb);
goto errout;
}
| 3,787 |
160,682 | 0 | void RenderFrameImpl::OnSerializeAsMHTML(
const FrameMsg_SerializeAsMHTML_Params& params) {
TRACE_EVENT0("page-serialization", "RenderFrameImpl::OnSerializeAsMHTML");
base::TimeTicks start_time = base::TimeTicks::Now();
base::File file = IPC::PlatformFileForTransitToFile(params.destination_file);
const WebString mhtml_boundary =
WebString::FromUTF8(params.mhtml_boundary_marker);
DCHECK(!mhtml_boundary.IsEmpty());
std::vector<WebThreadSafeData> mhtml_contents;
std::set<std::string> serialized_resources_uri_digests;
MHTMLPartsGenerationDelegate delegate(params,
&serialized_resources_uri_digests);
MhtmlSaveStatus save_status = MhtmlSaveStatus::SUCCESS;
bool has_some_data = false;
if (IsMainFrame()) {
TRACE_EVENT0("page-serialization",
"RenderFrameImpl::OnSerializeAsMHTML header");
mhtml_contents.emplace_back(WebFrameSerializer::GenerateMHTMLHeader(
mhtml_boundary, GetWebFrame(), &delegate));
if (mhtml_contents.back().IsEmpty())
save_status = MhtmlSaveStatus::FRAME_SERIALIZATION_FORBIDDEN;
else
has_some_data = true;
}
if (save_status == MhtmlSaveStatus::SUCCESS) {
TRACE_EVENT0("page-serialization",
"RenderFrameImpl::OnSerializeAsMHTML parts serialization");
mhtml_contents.emplace_back(WebFrameSerializer::GenerateMHTMLParts(
mhtml_boundary, GetWebFrame(), &delegate));
has_some_data |= !mhtml_contents.back().IsEmpty();
}
base::TimeDelta main_thread_use_time = base::TimeTicks::Now() - start_time;
UMA_HISTOGRAM_TIMES(
"PageSerialization.MhtmlGeneration.RendererMainThreadTime.SingleFrame",
main_thread_use_time);
if (save_status == MhtmlSaveStatus::SUCCESS && has_some_data) {
base::PostTaskAndReplyWithResult(
RenderThreadImpl::current()->GetFileThreadTaskRunner().get(), FROM_HERE,
base::Bind(&WriteMHTMLToDisk, base::Passed(&mhtml_contents),
base::Passed(&file)),
base::Bind(&RenderFrameImpl::OnWriteMHTMLToDiskComplete,
weak_factory_.GetWeakPtr(), params.job_id,
base::Passed(&serialized_resources_uri_digests),
main_thread_use_time));
} else {
file.Close();
OnWriteMHTMLToDiskComplete(params.job_id, serialized_resources_uri_digests,
main_thread_use_time, save_status);
}
}
| 3,788 |
111,532 | 0 | static AttributeTextStyle textStyleFromMask(int64_t mask)
{
AttributeTextStyle style;
if (mask & COMPOSED_TEXT_ATTRIB)
addCompositionTextStyleToAttributeTextStyle(style);
if (mask & ACTIVE_REGION_ATTRIB)
addActiveTextStyleToAttributeTextStyle(style);
return style;
}
| 3,789 |
129,750 | 0 | void ResourceFetcher::trace(Visitor* visitor)
{
visitor->trace(m_document);
ResourceLoaderHost::trace(visitor);
}
| 3,790 |
3,048 | 0 | static int ciedefgcompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace)
{
/* If the problems mentioned above are resolved, then this code could
* be re-instated.
*/
int code = 0;
ref CIEdict1, CIEdict2;
code = array_get(imemory, space, 1, &CIEdict1);
if (code < 0)
return 0;
code = array_get(imemory, testspace, 1, &CIEdict2);
if (code < 0)
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"WhitePoint"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"BlackPoint"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeABC"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeABC"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixABC"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeLMN"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeLMN"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixMN"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeDEFG"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeDEFG"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeHIJK"))
return 0;
if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"Table"))
return 0;
return 1;
}
| 3,791 |
185,860 | 1 | media::AudioParameters GetDeviceParametersOnDeviceThread(
media::AudioManager* audio_manager,
const std::string& unique_id) {
DCHECK(audio_manager->GetTaskRunner()->BelongsToCurrentThread());
return media::AudioDeviceDescription::IsDefaultDevice(unique_id)
? audio_manager->GetDefaultOutputStreamParameters()
: audio_manager->GetOutputStreamParameters(unique_id);
}
| 3,792 |
157,133 | 0 | void UrlData::DecreaseLoadersInState(
UrlDataWithLoadingState::LoadingState state) {
switch (state) {
case UrlDataWithLoadingState::LoadingState::kIdle:
return;
case UrlDataWithLoadingState::LoadingState::kPreload:
preloading_--;
DCHECK_GE(preloading_, 0);
break;
case UrlDataWithLoadingState::LoadingState::kHasPlayed:
playing_--;
DCHECK_GE(playing_, 0);
break;
}
if (preloading_ == 0 && playing_ == 0)
url_index_->RemoveLoading(this);
}
| 3,793 |
133,843 | 0 | void ReleaseProcessIfNeeded() {
content::UtilityThread::Get()->ReleaseProcessIfNeeded();
}
| 3,794 |
85,526 | 0 | int walk_page_buffers( handle_t *handle,
struct buffer_head *head,
unsigned from,
unsigned to,
int *partial,
int (*fn)( handle_t *handle,
struct buffer_head *bh))
{
struct buffer_head *bh;
unsigned block_start, block_end;
unsigned blocksize = head->b_size;
int err, ret = 0;
struct buffer_head *next;
for ( bh = head, block_start = 0;
ret == 0 && (bh != head || !block_start);
block_start = block_end, bh = next)
{
next = bh->b_this_page;
block_end = block_start + blocksize;
if (block_end <= from || block_start >= to) {
if (partial && !buffer_uptodate(bh))
*partial = 1;
continue;
}
err = (*fn)(handle, bh);
if (!ret)
ret = err;
}
return ret;
}
| 3,795 |
70,896 | 0 | static int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd)
{
int bytecnt = wpmd->byte_length;
char *byteptr = wpmd->data;
if (bytecnt != 4)
return FALSE;
wps->int32_sent_bits = *byteptr++;
wps->int32_zeros = *byteptr++;
wps->int32_ones = *byteptr++;
wps->int32_dups = *byteptr;
return TRUE;
}
| 3,796 |
124,480 | 0 | void RenderBlock::addOverflowFromChildren()
{
if (!hasColumns()) {
if (childrenInline())
toRenderBlockFlow(this)->addOverflowFromInlineChildren();
else
addOverflowFromBlockChildren();
} else {
ColumnInfo* colInfo = columnInfo();
if (columnCount(colInfo)) {
LayoutRect lastRect = columnRectAt(colInfo, columnCount(colInfo) - 1);
addLayoutOverflow(lastRect);
addContentsVisualOverflow(lastRect);
}
}
}
| 3,797 |
165,596 | 0 | bool FrameLoader::PrepareForCommit() {
PluginScriptForbiddenScope forbid_plugin_destructor_scripting;
DocumentLoader* pdl = provisional_document_loader_;
if (frame_->GetDocument()) {
unsigned node_count = 0;
for (Frame* frame = frame_; frame; frame = frame->Tree().TraverseNext()) {
if (frame->IsLocalFrame()) {
LocalFrame* local_frame = ToLocalFrame(frame);
node_count += local_frame->GetDocument()->NodeCount();
}
}
unsigned total_node_count =
InstanceCounters::CounterValue(InstanceCounters::kNodeCounter);
float ratio = static_cast<float>(node_count) / total_node_count;
ThreadState::Current()->SchedulePageNavigationGCIfNeeded(ratio);
}
SubframeLoadingDisabler disabler(frame_->GetDocument());
IgnoreOpensDuringUnloadCountIncrementer ignore_opens_during_unload(
frame_->GetDocument());
if (document_loader_) {
Client()->DispatchWillCommitProvisionalLoad();
DispatchUnloadEvent();
}
frame_->DetachChildren();
if (pdl != provisional_document_loader_)
return false;
if (document_loader_) {
base::AutoReset<bool> in_detach_document_loader(
&protect_provisional_loader_, true);
DetachDocumentLoader(document_loader_, true);
}
if (!frame_->Client())
return false;
DCHECK_EQ(provisional_document_loader_, pdl);
if (frame_->GetDocument())
frame_->GetDocument()->Shutdown();
document_loader_ = provisional_document_loader_.Release();
if (document_loader_)
document_loader_->MarkAsCommitted();
TakeObjectSnapshot();
return true;
}
| 3,798 |
95,195 | 0 | static int delmbox(const mbentry_t *mbentry, void *rock __attribute__((unused)))
{
int r;
if (!mboxlist_delayed_delete_isenabled()) {
r = mboxlist_deletemailbox(mbentry->name,
imapd_userisadmin || imapd_userisproxyadmin,
imapd_userid, imapd_authstate, NULL,
0, 0, 0);
} else if ((imapd_userisadmin || imapd_userisproxyadmin) &&
mboxname_isdeletedmailbox(mbentry->name, NULL)) {
r = mboxlist_deletemailbox(mbentry->name,
imapd_userisadmin || imapd_userisproxyadmin,
imapd_userid, imapd_authstate, NULL,
0, 0, 0);
} else {
r = mboxlist_delayed_deletemailbox(mbentry->name,
imapd_userisadmin || imapd_userisproxyadmin,
imapd_userid, imapd_authstate, NULL,
0, 0, 0);
}
if (r) {
prot_printf(imapd_out, "* NO delete %s: %s\r\n",
mbentry->name, error_message(r));
}
return 0;
}
| 3,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.