unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
176,762 | 0 | sp<IBinder> Parcel::readStrongBinder() const
{
sp<IBinder> val;
readStrongBinder(&val);
return val;
}
| 2,200 |
177,094 | 0 | SoftAMRNBEncoder::SoftAMRNBEncoder(
const char *name,
const OMX_CALLBACKTYPE *callbacks,
OMX_PTR appData,
OMX_COMPONENTTYPE **component)
: SimpleSoftOMXComponent(name, callbacks, appData, component),
mEncState(NULL),
mSidState(NULL),
mBitRate(0),
mMode(MR475),
mInputSize(0),
mInputTimeUs(-1ll),
mSawInputEOS(false),
mSignalledError(false) {
initPorts();
CHECK_EQ(initEncoder(), (status_t)OK);
}
| 2,201 |
104,006 | 0 | void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader");
ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram(
client_id, "glCompileShader");
if (!info) {
return;
}
const char* shader_src = info->source() ? info->source()->c_str() : "";
ShaderTranslator* translator = NULL;
if (use_shader_translator_) {
translator = info->shader_type() == GL_VERTEX_SHADER ?
vertex_translator_.get() : fragment_translator_.get();
if (!translator->Translate(shader_src)) {
info->SetStatus(false, translator->info_log(), NULL);
return;
}
shader_src = translator->translated_shader();
}
glShaderSource(info->service_id(), 1, &shader_src, NULL);
glCompileShader(info->service_id());
GLint status = GL_FALSE;
glGetShaderiv(info->service_id(), GL_COMPILE_STATUS, &status);
if (status) {
info->SetStatus(true, "", translator);
} else {
LOG_IF(ERROR, use_shader_translator_)
<< "Shader translator allowed/produced an invalid shader.";
GLint max_len = 0;
glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &max_len);
scoped_array<char> temp(new char[max_len]);
GLint len = 0;
glGetShaderInfoLog(info->service_id(), max_len, &len, temp.get());
DCHECK(max_len == 0 || len < max_len);
DCHECK(len ==0 || temp[len] == '\0');
info->SetStatus(false, std::string(temp.get(), len).c_str(), NULL);
}
};
| 2,202 |
84,036 | 0 | GF_Err hvcc_Read(GF_Box *s, GF_BitStream *bs)
{
u64 pos;
GF_HEVCConfigurationBox *ptr = (GF_HEVCConfigurationBox *)s;
if (ptr->config) gf_odf_hevc_cfg_del(ptr->config);
pos = gf_bs_get_position(bs);
ptr->config = gf_odf_hevc_cfg_read_bs(bs, (s->type == GF_ISOM_BOX_TYPE_HVCC) ? GF_FALSE : GF_TRUE);
pos = gf_bs_get_position(bs) - pos ;
if (pos < ptr->size)
ptr->size -= (u32) pos;
return ptr->config ? GF_OK : GF_ISOM_INVALID_FILE;
}
| 2,203 |
114,368 | 0 | void GpuChannel::OnDestroyCommandBuffer(int32 route_id,
IPC::Message* reply_message) {
#if defined(ENABLE_GPU)
TRACE_EVENT1("gpu", "GpuChannel::OnDestroyCommandBuffer",
"route_id", route_id);
if (router_.ResolveRoute(route_id)) {
GpuCommandBufferStub* stub = stubs_.Lookup(route_id);
bool need_reschedule = (stub && !stub->IsScheduled());
gfx::GpuPreference gpu_preference =
stub ? stub->gpu_preference() : gfx::PreferIntegratedGpu;
router_.RemoveRoute(route_id);
stubs_.Remove(route_id);
if (need_reschedule)
OnScheduled();
DidDestroyCommandBuffer(gpu_preference);
}
#endif
if (reply_message)
Send(reply_message);
}
| 2,204 |
90,817 | 0 | void gf_net_get_ntp(u32 *sec, u32 *frac)
{
u64 frac_part;
struct timeval now;
gettimeofday(&now, NULL);
if (sec) {
*sec = (u32) (now.tv_sec) + ntp_shift;
}
if (frac) {
frac_part = now.tv_usec * 0xFFFFFFFFULL;
frac_part /= 1000000;
*frac = (u32) ( frac_part );
}
}
| 2,205 |
83,183 | 0 | mrb_mod_module_eval(mrb_state *mrb, mrb_value mod)
{
mrb_value a, b;
if (mrb_get_args(mrb, "|S&", &a, &b) == 1) {
mrb_raise(mrb, E_NOTIMP_ERROR, "module_eval/class_eval with string not implemented");
}
return eval_under(mrb, mod, b, mrb_class_ptr(mod));
}
| 2,206 |
128,472 | 0 | bool ShellSurface::CanMaximize() const {
return true;
}
| 2,207 |
168,676 | 0 | void UiSceneCreator::CreateBackground() {
auto background =
Create<Background>(k2dBrowsingTexturedBackground, kPhaseBackground);
background->SetVisible(false);
background->AddBinding(base::MakeUnique<Binding<bool>>(
base::BindRepeating(
[](Model* m) {
return m->background_available && m->background_loaded;
},
base::Unretained(model_)),
base::BindRepeating([](UiElement* e, const bool& v) { e->SetVisible(v); },
base::Unretained(background.get()))));
scene_->AddUiElement(k2dBrowsingBackground, std::move(background));
auto element = Create<UiElement>(k2dBrowsingDefaultBackground, kPhaseNone);
element->set_hit_testable(false);
element->AddBinding(base::MakeUnique<Binding<bool>>(
base::BindRepeating([](Model* m) { return !m->background_available; },
base::Unretained(model_)),
base::BindRepeating([](UiElement* e, const bool& v) { e->SetVisible(v); },
base::Unretained(element.get()))));
scene_->AddUiElement(k2dBrowsingBackground, std::move(element));
struct Panel {
UiElementName name;
int x_offset;
int y_offset;
int z_offset;
int x_rotation;
int y_rotation;
int angle;
};
const std::vector<Panel> panels = {
{kBackgroundFront, 0, 0, -1, 0, 1, 0},
{kBackgroundLeft, -1, 0, 0, 0, 1, 1},
{kBackgroundBack, 0, 0, 1, 0, 1, 2},
{kBackgroundRight, 1, 0, 0, 0, 1, 3},
{kBackgroundTop, 0, 1, 0, 1, 0, 1},
{kBackgroundBottom, 0, -1, 0, 1, 0, -1},
};
for (auto& panel : panels) {
auto panel_element = Create<Rect>(panel.name, kPhaseBackground);
panel_element->SetSize(kSceneSize, kSceneSize);
panel_element->SetTranslate(panel.x_offset * kSceneSize / 2,
panel.y_offset * kSceneSize / 2,
panel.z_offset * kSceneSize / 2);
panel_element->SetRotate(panel.x_rotation, panel.y_rotation, 0,
base::kPiFloat / 2 * panel.angle);
panel_element->set_hit_testable(false);
BindColor(model_, panel_element.get(), &ColorScheme::world_background,
&Rect::SetColor);
panel_element->AddBinding(
VR_BIND_FUNC(bool, Model, model_, should_render_web_vr() == false,
UiElement, panel_element.get(), SetVisible));
scene_->AddUiElement(k2dBrowsingDefaultBackground,
std::move(panel_element));
}
auto floor = Create<Grid>(kFloor, kPhaseFloorCeiling);
floor->SetSize(kSceneSize, kSceneSize);
floor->SetTranslate(0.0, -kSceneHeight / 2, 0.0);
floor->SetRotate(1, 0, 0, -base::kPiFloat / 2);
floor->set_gridline_count(kFloorGridlineCount);
floor->set_focusable(false);
BindColor(model_, floor.get(), &ColorScheme::floor, &Grid::SetCenterColor);
BindColor(model_, floor.get(), &ColorScheme::world_background,
&Grid::SetEdgeColor);
BindColor(model_, floor.get(), &ColorScheme::floor_grid, &Grid::SetGridColor);
scene_->AddUiElement(k2dBrowsingDefaultBackground, std::move(floor));
auto ceiling = Create<Rect>(kCeiling, kPhaseFloorCeiling);
ceiling->set_focusable(false);
ceiling->SetSize(kSceneSize, kSceneSize);
ceiling->SetTranslate(0.0, kSceneHeight / 2, 0.0);
ceiling->SetRotate(1, 0, 0, base::kPiFloat / 2);
BindColor(model_, ceiling.get(), &ColorScheme::ceiling,
&Rect::SetCenterColor);
BindColor(model_, ceiling.get(), &ColorScheme::world_background,
&Rect::SetEdgeColor);
scene_->AddUiElement(k2dBrowsingDefaultBackground, std::move(ceiling));
}
| 2,208 |
98,465 | 0 | HRESULT CallDwmSetIconicLivePreviewBitmap(HWND window,
HBITMAP bitmap,
POINT* client,
DWORD flags) {
FilePath dwmapi_path(base::GetNativeLibraryName(L"dwmapi"));
base::ScopedNativeLibrary dwmapi(dwmapi_path);
typedef HRESULT (STDAPICALLTYPE *DwmSetIconicLivePreviewBitmapProc)(
HWND, HBITMAP, POINT*, DWORD);
DwmSetIconicLivePreviewBitmapProc dwm_set_live_preview_bitmap =
static_cast<DwmSetIconicLivePreviewBitmapProc>(
dwmapi.GetFunctionPointer("DwmSetIconicLivePreviewBitmap"));
if (!dwm_set_live_preview_bitmap)
return E_FAIL;
return dwm_set_live_preview_bitmap(window, bitmap, client, flags);
}
| 2,209 |
13,623 | 0 | static long ebcdic_ctrl(BIO *b, int cmd, long num, void *ptr)
{
long ret;
if (b->next_bio == NULL)
return (0);
switch (cmd) {
case BIO_CTRL_DUP:
ret = 0L;
break;
default:
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
}
return (ret);
}
| 2,210 |
172,766 | 0 | status_t MPEG4Extractor::parseDrmSINF(
off64_t * /* offset */, off64_t data_offset) {
uint8_t updateIdTag;
if (mDataSource->readAt(data_offset, &updateIdTag, 1) < 1) {
return ERROR_IO;
}
data_offset ++;
if (0x01/*OBJECT_DESCRIPTOR_UPDATE_ID_TAG*/ != updateIdTag) {
return ERROR_MALFORMED;
}
uint8_t numOfBytes;
int32_t size = readSize(data_offset, mDataSource, &numOfBytes);
if (size < 0) {
return ERROR_IO;
}
data_offset += numOfBytes;
while(size >= 11 ) {
uint8_t descriptorTag;
if (mDataSource->readAt(data_offset, &descriptorTag, 1) < 1) {
return ERROR_IO;
}
data_offset ++;
if (0x11/*OBJECT_DESCRIPTOR_ID_TAG*/ != descriptorTag) {
return ERROR_MALFORMED;
}
uint8_t buffer[8];
if (mDataSource->readAt(data_offset, buffer, 2) < 2) {
return ERROR_IO;
}
data_offset += 2;
if ((buffer[1] >> 5) & 0x0001) { //url flag is set
return ERROR_MALFORMED;
}
if (mDataSource->readAt(data_offset, buffer, 8) < 8) {
return ERROR_IO;
}
data_offset += 8;
if ((0x0F/*ES_ID_REF_TAG*/ != buffer[1])
|| ( 0x0A/*IPMP_DESCRIPTOR_POINTER_ID_TAG*/ != buffer[5])) {
return ERROR_MALFORMED;
}
SINF *sinf = new SINF;
sinf->trackID = U16_AT(&buffer[3]);
sinf->IPMPDescriptorID = buffer[7];
sinf->next = mFirstSINF;
mFirstSINF = sinf;
size -= (8 + 2 + 1);
}
if (size != 0) {
return ERROR_MALFORMED;
}
if (mDataSource->readAt(data_offset, &updateIdTag, 1) < 1) {
return ERROR_IO;
}
data_offset ++;
if(0x05/*IPMP_DESCRIPTOR_UPDATE_ID_TAG*/ != updateIdTag) {
return ERROR_MALFORMED;
}
size = readSize(data_offset, mDataSource, &numOfBytes);
if (size < 0) {
return ERROR_IO;
}
data_offset += numOfBytes;
while (size > 0) {
uint8_t tag;
int32_t dataLen;
if (mDataSource->readAt(data_offset, &tag, 1) < 1) {
return ERROR_IO;
}
data_offset ++;
if (0x0B/*IPMP_DESCRIPTOR_ID_TAG*/ == tag) {
uint8_t id;
dataLen = readSize(data_offset, mDataSource, &numOfBytes);
if (dataLen < 0) {
return ERROR_IO;
} else if (dataLen < 4) {
return ERROR_MALFORMED;
}
data_offset += numOfBytes;
if (mDataSource->readAt(data_offset, &id, 1) < 1) {
return ERROR_IO;
}
data_offset ++;
SINF *sinf = mFirstSINF;
while (sinf && (sinf->IPMPDescriptorID != id)) {
sinf = sinf->next;
}
if (sinf == NULL) {
return ERROR_MALFORMED;
}
sinf->len = dataLen - 3;
sinf->IPMPData = new (std::nothrow) char[sinf->len];
if (sinf->IPMPData == NULL) {
return ERROR_MALFORMED;
}
data_offset += 2;
if (mDataSource->readAt(data_offset, sinf->IPMPData, sinf->len) < sinf->len) {
return ERROR_IO;
}
data_offset += sinf->len;
size -= (dataLen + numOfBytes + 1);
}
}
if (size != 0) {
return ERROR_MALFORMED;
}
return UNKNOWN_ERROR; // Return a dummy error.
}
| 2,211 |
15,246 | 0 | PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *var_array, zval *ids_array, ulong opt, char **sql TSRMLS_DC)
{
zval *var_converted = NULL, *ids_converted = NULL;
smart_str querystr = {0};
int ret = FAILURE;
assert(pg_link != NULL);
assert(table != NULL);
assert(Z_TYPE_P(var_array) == IS_ARRAY);
assert(Z_TYPE_P(ids_array) == IS_ARRAY);
assert(!(opt & ~(PGSQL_CONV_OPTS|PGSQL_DML_NO_CONV|PGSQL_DML_EXEC|PGSQL_DML_STRING)));
if (zend_hash_num_elements(Z_ARRVAL_P(var_array)) == 0
|| zend_hash_num_elements(Z_ARRVAL_P(ids_array)) == 0) {
return FAILURE;
}
if (!(opt & PGSQL_DML_NO_CONV)) {
MAKE_STD_ZVAL(var_converted);
array_init(var_converted);
if (php_pgsql_convert(pg_link, table, var_array, var_converted, (opt & PGSQL_CONV_OPTS) TSRMLS_CC) == FAILURE) {
goto cleanup;
}
var_array = var_converted;
MAKE_STD_ZVAL(ids_converted);
array_init(ids_converted);
if (php_pgsql_convert(pg_link, table, ids_array, ids_converted, (opt & PGSQL_CONV_OPTS) TSRMLS_CC) == FAILURE) {
goto cleanup;
}
ids_array = ids_converted;
}
smart_str_appends(&querystr, "UPDATE ");
build_tablename(&querystr, pg_link, table);
smart_str_appends(&querystr, " SET ");
if (build_assignment_string(&querystr, Z_ARRVAL_P(var_array), 0, ",", 1 TSRMLS_CC))
goto cleanup;
smart_str_appends(&querystr, " WHERE ");
if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC))
goto cleanup;
smart_str_appendc(&querystr, ';');
smart_str_0(&querystr);
if ((opt & PGSQL_DML_EXEC) && do_exec(&querystr, PGRES_COMMAND_OK, pg_link, opt TSRMLS_CC) == 0) {
ret = SUCCESS;
} else if (opt & PGSQL_DML_STRING) {
ret = SUCCESS;
}
cleanup:
if (var_converted) {
zval_dtor(var_converted);
FREE_ZVAL(var_converted);
}
if (ids_converted) {
zval_dtor(ids_converted);
FREE_ZVAL(ids_converted);
}
if (ret == SUCCESS && (opt & PGSQL_DML_STRING)) {
*sql = querystr.c;
}
else {
smart_str_free(&querystr);
}
return ret;
}
| 2,212 |
64,537 | 0 | MagickExport MagickBooleanType SetImageStorageClass(Image *image,
const ClassType storage_class)
{
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
image->storage_class=storage_class;
return(SyncImagePixelCache(image,&image->exception));
}
| 2,213 |
144,478 | 0 | void WebContentsImpl::DidFinishNavigation(NavigationHandle* navigation_handle) {
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
DidFinishNavigation(navigation_handle));
}
| 2,214 |
923 | 0 | void CairoOutputDev::stroke(GfxState *state) {
doPath (cairo, state, state->getPath());
cairo_set_source (cairo, stroke_pattern);
LOG(printf ("stroke\n"));
cairo_stroke (cairo);
if (cairo_shape) {
doPath (cairo_shape, state, state->getPath());
cairo_stroke (cairo_shape);
}
}
| 2,215 |
48,980 | 0 | static int ipv6_gro_complete(struct sk_buff *skb, int nhoff)
{
const struct net_offload *ops;
struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + nhoff);
int err = -ENOSYS;
if (skb->encapsulation)
skb_set_inner_network_header(skb, nhoff);
iph->payload_len = htons(skb->len - nhoff - sizeof(*iph));
rcu_read_lock();
nhoff += sizeof(*iph) + ipv6_exthdrs_len(iph, &ops);
if (WARN_ON(!ops || !ops->callbacks.gro_complete))
goto out_unlock;
err = ops->callbacks.gro_complete(skb, nhoff);
out_unlock:
rcu_read_unlock();
return err;
}
| 2,216 |
40,856 | 0 | wkbReadPointP(wkbObj *w, pointObj *p)
{
memcpy(&(p->x), w->ptr, sizeof(double));
w->ptr += sizeof(double);
memcpy(&(p->y), w->ptr, sizeof(double));
w->ptr += sizeof(double);
}
| 2,217 |
4,819 | 0 | DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev,
enum InputLevel level)
{
SpritePtr pSprite = dev->spriteInfo->sprite;
int rc;
xEvent *xE = NULL;
int count = 0;
int deliveries = 0;
Mask mask;
GrabInfoPtr grabinfo = &dev->deviceGrab;
GrabPtr grab = grabinfo->grab;
Mask filter;
if (grab->grabtype != level)
return 0;
switch (level) {
case XI2:
rc = EventToXI2(event, &xE);
count = 1;
if (rc == Success) {
int evtype = xi2_get_type(xE);
mask = GetXI2MaskByte(grab->xi2mask, dev, evtype);
filter = GetEventFilter(dev, xE);
}
break;
case XI:
if (grabinfo->fromPassiveGrab && grabinfo->implicitGrab)
mask = grab->deviceMask;
else
mask = grab->eventMask;
rc = EventToXI(event, &xE, &count);
if (rc == Success)
filter = GetEventFilter(dev, xE);
break;
case CORE:
rc = EventToCore(event, &xE, &count);
mask = grab->eventMask;
if (rc == Success)
filter = GetEventFilter(dev, xE);
break;
default:
BUG_WARN_MSG(1, "Invalid input level %d\n", level);
return 0;
}
if (rc == Success) {
FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
if (XaceHook(XACE_SEND_ACCESS, 0, dev,
grab->window, xE, count) ||
XaceHook(XACE_RECEIVE_ACCESS, rClient(grab),
grab->window, xE, count))
deliveries = 1; /* don't send, but pretend we did */
else if (level != CORE || !IsInterferingGrab(rClient(grab), dev, xE)) {
deliveries = TryClientEvents(rClient(grab), dev,
xE, count, mask, filter, grab);
}
}
else
BUG_WARN_MSG(rc != BadMatch,
"%s: conversion to mode %d failed on %d with %d\n",
dev->name, level, event->any.type, rc);
free(xE);
return deliveries;
}
| 2,218 |
52,901 | 0 | static void ib_uverbs_release_event_file(struct kref *ref)
{
struct ib_uverbs_event_file *file =
container_of(ref, struct ib_uverbs_event_file, ref);
kfree(file);
}
| 2,219 |
149,057 | 0 | static void checkAppendMsg(
IntegrityCk *pCheck,
const char *zFormat,
...
){
va_list ap;
if( !pCheck->mxErr ) return;
pCheck->mxErr--;
pCheck->nErr++;
va_start(ap, zFormat);
if( pCheck->errMsg.nChar ){
sqlite3StrAccumAppend(&pCheck->errMsg, "\n", 1);
}
if( pCheck->zPfx ){
sqlite3XPrintf(&pCheck->errMsg, pCheck->zPfx, pCheck->v1, pCheck->v2);
}
sqlite3VXPrintf(&pCheck->errMsg, zFormat, ap);
va_end(ap);
if( pCheck->errMsg.accError==STRACCUM_NOMEM ){
pCheck->mallocFailed = 1;
}
}
| 2,220 |
176,895 | 0 | void InputDispatcher::addMonitoringTargetsLocked(Vector<InputTarget>& inputTargets) {
for (size_t i = 0; i < mMonitoringChannels.size(); i++) {
inputTargets.push();
InputTarget& target = inputTargets.editTop();
target.inputChannel = mMonitoringChannels[i];
target.flags = InputTarget::FLAG_DISPATCH_AS_IS;
target.xOffset = 0;
target.yOffset = 0;
target.pointerIds.clear();
target.scaleFactor = 1.0f;
}
}
| 2,221 |
1,531 | 0 | z2grestoreall(i_ctx_t *i_ctx_p)
{
for (;;) {
int code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
if (code < 0) return code;
if (code == 0) {
bool done = !gs_gstate_saved(gs_gstate_saved(igs));
gs_grestore(igs);
if (done)
break;
} else
return push_callout(i_ctx_p, "%grestoreallpagedevice");
}
return 0;
}
| 2,222 |
152,343 | 0 | GURL RenderFrameImpl::GetLoadingUrl() const {
WebDocumentLoader* document_loader = frame_->GetDocumentLoader();
GURL overriden_url;
if (MaybeGetOverriddenURL(document_loader, &overriden_url))
return overriden_url;
return document_loader->GetUrl();
}
| 2,223 |
149,937 | 0 | void DidVisibilityChange(LayerTreeHostImpl* id, bool visible) {
if (visible) {
TRACE_EVENT_ASYNC_BEGIN1("cc", "LayerTreeHostImpl::SetVisible", id,
"LayerTreeHostImpl", id);
return;
}
TRACE_EVENT_ASYNC_END0("cc", "LayerTreeHostImpl::SetVisible", id);
}
| 2,224 |
45,716 | 0 | static struct crypto_instance *eseqiv_alloc(struct rtattr **tb)
{
struct crypto_instance *inst;
int err;
err = crypto_get_default_rng();
if (err)
return ERR_PTR(err);
inst = skcipher_geniv_alloc(&eseqiv_tmpl, tb, 0, 0);
if (IS_ERR(inst))
goto put_rng;
err = -EINVAL;
if (inst->alg.cra_ablkcipher.ivsize != inst->alg.cra_blocksize)
goto free_inst;
inst->alg.cra_ablkcipher.givencrypt = eseqiv_givencrypt_first;
inst->alg.cra_init = eseqiv_init;
inst->alg.cra_exit = skcipher_geniv_exit;
inst->alg.cra_ctxsize = sizeof(struct eseqiv_ctx);
inst->alg.cra_ctxsize += inst->alg.cra_ablkcipher.ivsize;
out:
return inst;
free_inst:
skcipher_geniv_free(inst);
inst = ERR_PTR(err);
put_rng:
crypto_put_default_rng();
goto out;
}
| 2,225 |
49,500 | 0 | const struct hid_device_id *hid_match_id(struct hid_device *hdev,
const struct hid_device_id *id)
{
for (; id->bus; id++)
if (hid_match_one_id(hdev, id))
return id;
return NULL;
}
| 2,226 |
187,577 | 1 | void bdt_enable(void)
{
bdt_log("ENABLE BT");
if (bt_enabled) {
bdt_log("Bluetooth is already enabled");
return;
}
status = sBtInterface->enable();
check_return_status(status);
}
| 2,227 |
21,746 | 0 | static int em_dr_write(struct x86_emulate_ctxt *ctxt)
{
unsigned long val;
if (ctxt->mode == X86EMUL_MODE_PROT64)
val = ctxt->src.val & ~0ULL;
else
val = ctxt->src.val & ~0U;
/* #UD condition is already handled. */
if (ctxt->ops->set_dr(ctxt, ctxt->modrm_reg, val) < 0)
return emulate_gp(ctxt, 0);
/* Disable writeback. */
ctxt->dst.type = OP_NONE;
return X86EMUL_CONTINUE;
}
| 2,228 |
45,100 | 0 | static int lua_get_cookie(lua_State *L)
{
const char *key, *cookie;
request_rec *r = ap_lua_check_request_rec(L, 1);
key = luaL_checkstring(L, 2);
cookie = NULL;
ap_cookie_read(r, key, &cookie, 0);
if (cookie != NULL) {
lua_pushstring(L, cookie);
return 1;
}
return 0;
}
| 2,229 |
182,412 | 1 | void mp_encode_lua_table_as_map(lua_State *L, mp_buf *buf, int level) {
size_t len = 0;
/* First step: count keys into table. No other way to do it with the
* Lua API, we need to iterate a first time. Note that an alternative
* would be to do a single run, and then hack the buffer to insert the
* map opcodes for message pack. Too hackish for this lib. */
lua_pushnil(L);
while(lua_next(L,-2)) {
lua_pop(L,1); /* remove value, keep key for next iteration. */
len++;
}
/* Step two: actually encoding of the map. */
mp_encode_map(L,buf,len);
lua_pushnil(L);
while(lua_next(L,-2)) {
/* Stack: ... key value */
lua_pushvalue(L,-2); /* Stack: ... key value key */
mp_encode_lua_type(L,buf,level+1); /* encode key */
mp_encode_lua_type(L,buf,level+1); /* encode val */
}
}
| 2,230 |
75,928 | 0 | connection_timeout(thread_t * thread)
{
smtp_t *smtp = THREAD_ARG(thread);
log_message(LOG_INFO, "Timeout connecting SMTP server %s."
, FMT_SMTP_HOST());
free_smtp_all(smtp);
return 0;
}
| 2,231 |
113,399 | 0 | void WebProcessProxy::getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply)
{
m_context->getNetworkProcessConnection(reply);
}
| 2,232 |
132,516 | 0 | UsbGetUserSelectedDevicesFunction::~UsbGetUserSelectedDevicesFunction() {
}
| 2,233 |
96,496 | 0 | static void AppLayerProtoDetectProbingParserAppend(AppLayerProtoDetectProbingParser **head_pp,
AppLayerProtoDetectProbingParser *new_pp)
{
SCEnter();
if (*head_pp == NULL) {
*head_pp = new_pp;
goto end;
}
AppLayerProtoDetectProbingParser *temp_pp = *head_pp;
while (temp_pp->next != NULL)
temp_pp = temp_pp->next;
temp_pp->next = new_pp;
end:
SCReturn;
}
| 2,234 |
3,125 | 0 | static int sepbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth)
{
os_ptr op = osp; /* required by "push" macro */
int use, code;
code = septransform(i_ctx_p, space, &use, stage, stack_depth);
if (code != 0)
return code;
if (!use) {
*stage = 0;
*cont = 0;
pop(1);
op = osp;
switch(base) {
case 0:
push(1);
make_real(op, 0.0);
break;
case 1:
case 2:
push(3);
make_real(&op[-2], 0.0);
make_real(&op[-1], 0.0);
make_real(op, 0.0);
break;
case 3:
push(4);
make_real(&op[-3], 0.0);
make_real(&op[-2], 0.0);
make_real(&op[-1], 0.0);
make_real(op, 0.0);
break;
}
} else {
*stage = 0;
*cont = 1;
}
return 0;
}
| 2,235 |
42,977 | 0 | static void refill_work(struct work_struct *work)
{
struct virtnet_info *vi =
container_of(work, struct virtnet_info, refill.work);
bool still_empty;
int i;
for (i = 0; i < vi->curr_queue_pairs; i++) {
struct receive_queue *rq = &vi->rq[i];
napi_disable(&rq->napi);
still_empty = !try_fill_recv(vi, rq, GFP_KERNEL);
virtnet_napi_enable(rq);
/* In theory, this can happen: if we don't get any buffers in
* we will *never* try to fill again.
*/
if (still_empty)
schedule_delayed_work(&vi->refill, HZ/2);
}
}
| 2,236 |
104,430 | 0 | GLvoid StubGLDeleteProgram(GLuint program) {
glDeleteProgram(program);
}
| 2,237 |
38,314 | 0 | static int page_not_mapped(struct page *page)
{
return !page_mapped(page);
};
| 2,238 |
51,594 | 0 | int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
{
struct tcp_sock *tp = tcp_sk(sk);
struct inet_connection_sock *icsk = inet_csk(sk);
const struct tcphdr *th = tcp_hdr(skb);
struct request_sock *req;
int queued = 0;
bool acceptable;
switch (sk->sk_state) {
case TCP_CLOSE:
goto discard;
case TCP_LISTEN:
if (th->ack)
return 1;
if (th->rst)
goto discard;
if (th->syn) {
if (th->fin)
goto discard;
if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
return 1;
consume_skb(skb);
return 0;
}
goto discard;
case TCP_SYN_SENT:
tp->rx_opt.saw_tstamp = 0;
queued = tcp_rcv_synsent_state_process(sk, skb, th);
if (queued >= 0)
return queued;
/* Do step6 onward by hand. */
tcp_urg(sk, skb, th);
__kfree_skb(skb);
tcp_data_snd_check(sk);
return 0;
}
tp->rx_opt.saw_tstamp = 0;
req = tp->fastopen_rsk;
if (req) {
WARN_ON_ONCE(sk->sk_state != TCP_SYN_RECV &&
sk->sk_state != TCP_FIN_WAIT1);
if (!tcp_check_req(sk, skb, req, true))
goto discard;
}
if (!th->ack && !th->rst && !th->syn)
goto discard;
if (!tcp_validate_incoming(sk, skb, th, 0))
return 0;
/* step 5: check the ACK field */
acceptable = tcp_ack(sk, skb, FLAG_SLOWPATH |
FLAG_UPDATE_TS_RECENT) > 0;
switch (sk->sk_state) {
case TCP_SYN_RECV:
if (!acceptable)
return 1;
if (!tp->srtt_us)
tcp_synack_rtt_meas(sk, req);
/* Once we leave TCP_SYN_RECV, we no longer need req
* so release it.
*/
if (req) {
tp->total_retrans = req->num_retrans;
reqsk_fastopen_remove(sk, req, false);
} else {
/* Make sure socket is routed, for correct metrics. */
icsk->icsk_af_ops->rebuild_header(sk);
tcp_init_congestion_control(sk);
tcp_mtup_init(sk);
tp->copied_seq = tp->rcv_nxt;
tcp_init_buffer_space(sk);
}
smp_mb();
tcp_set_state(sk, TCP_ESTABLISHED);
sk->sk_state_change(sk);
/* Note, that this wakeup is only for marginal crossed SYN case.
* Passively open sockets are not waked up, because
* sk->sk_sleep == NULL and sk->sk_socket == NULL.
*/
if (sk->sk_socket)
sk_wake_async(sk, SOCK_WAKE_IO, POLL_OUT);
tp->snd_una = TCP_SKB_CB(skb)->ack_seq;
tp->snd_wnd = ntohs(th->window) << tp->rx_opt.snd_wscale;
tcp_init_wl(tp, TCP_SKB_CB(skb)->seq);
if (tp->rx_opt.tstamp_ok)
tp->advmss -= TCPOLEN_TSTAMP_ALIGNED;
if (req) {
/* Re-arm the timer because data may have been sent out.
* This is similar to the regular data transmission case
* when new data has just been ack'ed.
*
* (TFO) - we could try to be more aggressive and
* retransmitting any data sooner based on when they
* are sent out.
*/
tcp_rearm_rto(sk);
} else
tcp_init_metrics(sk);
tcp_update_pacing_rate(sk);
/* Prevent spurious tcp_cwnd_restart() on first data packet */
tp->lsndtime = tcp_time_stamp;
tcp_initialize_rcv_mss(sk);
tcp_fast_path_on(tp);
break;
case TCP_FIN_WAIT1: {
struct dst_entry *dst;
int tmo;
/* If we enter the TCP_FIN_WAIT1 state and we are a
* Fast Open socket and this is the first acceptable
* ACK we have received, this would have acknowledged
* our SYNACK so stop the SYNACK timer.
*/
if (req) {
/* Return RST if ack_seq is invalid.
* Note that RFC793 only says to generate a
* DUPACK for it but for TCP Fast Open it seems
* better to treat this case like TCP_SYN_RECV
* above.
*/
if (!acceptable)
return 1;
/* We no longer need the request sock. */
reqsk_fastopen_remove(sk, req, false);
tcp_rearm_rto(sk);
}
if (tp->snd_una != tp->write_seq)
break;
tcp_set_state(sk, TCP_FIN_WAIT2);
sk->sk_shutdown |= SEND_SHUTDOWN;
dst = __sk_dst_get(sk);
if (dst)
dst_confirm(dst);
if (!sock_flag(sk, SOCK_DEAD)) {
/* Wake up lingering close() */
sk->sk_state_change(sk);
break;
}
if (tp->linger2 < 0 ||
(TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt))) {
tcp_done(sk);
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA);
return 1;
}
tmo = tcp_fin_time(sk);
if (tmo > TCP_TIMEWAIT_LEN) {
inet_csk_reset_keepalive_timer(sk, tmo - TCP_TIMEWAIT_LEN);
} else if (th->fin || sock_owned_by_user(sk)) {
/* Bad case. We could lose such FIN otherwise.
* It is not a big problem, but it looks confusing
* and not so rare event. We still can lose it now,
* if it spins in bh_lock_sock(), but it is really
* marginal case.
*/
inet_csk_reset_keepalive_timer(sk, tmo);
} else {
tcp_time_wait(sk, TCP_FIN_WAIT2, tmo);
goto discard;
}
break;
}
case TCP_CLOSING:
if (tp->snd_una == tp->write_seq) {
tcp_time_wait(sk, TCP_TIME_WAIT, 0);
goto discard;
}
break;
case TCP_LAST_ACK:
if (tp->snd_una == tp->write_seq) {
tcp_update_metrics(sk);
tcp_done(sk);
goto discard;
}
break;
}
/* step 6: check the URG bit */
tcp_urg(sk, skb, th);
/* step 7: process the segment text */
switch (sk->sk_state) {
case TCP_CLOSE_WAIT:
case TCP_CLOSING:
case TCP_LAST_ACK:
if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt))
break;
case TCP_FIN_WAIT1:
case TCP_FIN_WAIT2:
/* RFC 793 says to queue data in these states,
* RFC 1122 says we MUST send a reset.
* BSD 4.4 also does reset.
*/
if (sk->sk_shutdown & RCV_SHUTDOWN) {
if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) {
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA);
tcp_reset(sk);
return 1;
}
}
/* Fall through */
case TCP_ESTABLISHED:
tcp_data_queue(sk, skb);
queued = 1;
break;
}
/* tcp_data could move socket to TIME-WAIT */
if (sk->sk_state != TCP_CLOSE) {
tcp_data_snd_check(sk);
tcp_ack_snd_check(sk);
}
if (!queued) {
discard:
tcp_drop(sk, skb);
}
return 0;
}
| 2,239 |
149,456 | 0 | bool ContentSecurityPolicy::isNonceableElement(const Element* element) {
if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled() &&
isHTMLScriptElement(element)) {
if (toHTMLScriptElement(element)->nonce().isNull())
return false;
} else if (!element->fastHasAttribute(HTMLNames::nonceAttr)) {
return false;
}
bool nonceable = true;
static const char scriptString[] = "<script";
static const char styleString[] = "<style";
for (const Attribute& attr : element->attributes()) {
AtomicString name = attr.localName().lowerASCII();
AtomicString value = attr.value().lowerASCII();
if (name.find(scriptString) != WTF::kNotFound ||
name.find(styleString) != WTF::kNotFound ||
value.find(scriptString) != WTF::kNotFound ||
value.find(styleString) != WTF::kNotFound) {
nonceable = false;
break;
}
}
UseCounter::count(
element->document(),
nonceable ? UseCounter::CleanScriptElementWithNonce
: UseCounter::PotentiallyInjectedScriptElementWithNonce);
return !RuntimeEnabledFeatures::
experimentalContentSecurityPolicyFeaturesEnabled() ||
nonceable;
}
| 2,240 |
98,783 | 0 | void WebPluginDelegateProxy::OnAcceleratedSurfaceBuffersSwapped(
gfx::PluginWindowHandle window) {
if (render_view_)
render_view_->AcceleratedSurfaceBuffersSwapped(window);
}
| 2,241 |
45,841 | 0 | static int mcryptd_hash_setkey(struct crypto_ahash *parent,
const u8 *key, unsigned int keylen)
{
struct mcryptd_hash_ctx *ctx = crypto_ahash_ctx(parent);
struct crypto_shash *child = ctx->child;
int err;
crypto_shash_clear_flags(child, CRYPTO_TFM_REQ_MASK);
crypto_shash_set_flags(child, crypto_ahash_get_flags(parent) &
CRYPTO_TFM_REQ_MASK);
err = crypto_shash_setkey(child, key, keylen);
crypto_ahash_set_flags(parent, crypto_shash_get_flags(child) &
CRYPTO_TFM_RES_MASK);
return err;
}
| 2,242 |
36,777 | 0 | spnego_gss_unwrap_aead(OM_uint32 *minor_status,
gss_ctx_id_t context_handle,
gss_buffer_t input_message_buffer,
gss_buffer_t input_assoc_buffer,
gss_buffer_t output_payload_buffer,
int *conf_state,
gss_qop_t *qop_state)
{
OM_uint32 ret;
ret = gss_unwrap_aead(minor_status,
context_handle,
input_message_buffer,
input_assoc_buffer,
output_payload_buffer,
conf_state,
qop_state);
return (ret);
}
| 2,243 |
73,659 | 0 | MagickExport MagickBooleanType SyncAuthenticPixelCacheNexus(Image *image,
NexusInfo *restrict nexus_info,ExceptionInfo *exception)
{
CacheInfo
*restrict cache_info;
MagickBooleanType
status;
/*
Transfer pixels to the cache.
*/
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->cache == (Cache) NULL)
ThrowBinaryException(CacheError,"PixelCacheIsNotOpen",image->filename);
cache_info=(CacheInfo *) image->cache;
assert(cache_info->signature == MagickSignature);
if (cache_info->type == UndefinedCache)
return(MagickFalse);
if ((image->storage_class == DirectClass) &&
(image->clip_mask != (Image *) NULL) &&
(ClipPixelCacheNexus(image,nexus_info,exception) == MagickFalse))
return(MagickFalse);
if ((image->storage_class == DirectClass) &&
(image->mask != (Image *) NULL) &&
(MaskPixelCacheNexus(image,nexus_info,exception) == MagickFalse))
return(MagickFalse);
if (nexus_info->authentic_pixel_cache != MagickFalse)
{
image->taint=MagickTrue;
return(MagickTrue);
}
assert(cache_info->signature == MagickSignature);
status=WritePixelCachePixels(cache_info,nexus_info,exception);
if ((cache_info->active_index_channel != MagickFalse) &&
(WritePixelCacheIndexes(cache_info,nexus_info,exception) == MagickFalse))
return(MagickFalse);
if (status != MagickFalse)
image->taint=MagickTrue;
return(status);
}
| 2,244 |
155,036 | 0 | ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* script_state,
const String& name) {
WebGLExtension* extension = nullptr;
if (name == WebGLDebugRendererInfo::ExtensionName()) {
ExecutionContext* context = ExecutionContext::From(script_state);
UseCounter::Count(context, WebFeature::kWebGLDebugRendererInfo);
Dactyloscoper::Record(context, WebFeature::kWebGLDebugRendererInfo);
}
if (!isContextLost()) {
for (ExtensionTracker* tracker : extensions_) {
if (tracker->MatchesNameWithPrefixes(name)) {
if (ExtensionSupportedAndAllowed(tracker)) {
extension = tracker->GetExtension(this);
if (extension) {
if (!extension_enabled_[extension->GetName()]) {
extension_enabled_[extension->GetName()] = true;
}
}
}
break;
}
}
}
v8::Local<v8::Value> wrapped_extension =
ToV8(extension, script_state->GetContext()->Global(),
script_state->GetIsolate());
return ScriptValue(script_state, wrapped_extension);
}
| 2,245 |
10,125 | 0 | Ins_LTEQ( INS_ARG )
{
DO_LTEQ
}
| 2,246 |
136,343 | 0 | const ClipPaintPropertyNode* PaintPropertyTreeBuilderTest::DocContentClip(
const Document* document) {
if (!document)
document = &GetDocument();
return document->GetLayoutView()
->FirstFragment()
.PaintProperties()
->OverflowClip();
}
| 2,247 |
40,868 | 0 | size_t hashtable_iter_serial(void *iter)
{
pair_t *pair = list_to_pair((list_t *)iter);
return pair->serial;
}
| 2,248 |
51,903 | 0 | AirPDcapGetStaAddress(
const AIRPDCAP_MAC_FRAME_ADDR4 *frame)
{
switch(AIRPDCAP_DS_BITS(frame->fc[1])) { /* Bit 1 = FromDS, bit 0 = ToDS */
case 0:
if (memcmp(frame->addr2, frame->addr3, AIRPDCAP_MAC_LEN) == 0)
return frame->addr1;
else
return frame->addr2;
case 1:
return frame->addr2;
case 2:
return frame->addr1;
case 3:
if (memcmp(frame->addr1, frame->addr2, AIRPDCAP_MAC_LEN) < 0)
return frame->addr1;
else
return frame->addr2;
default:
return NULL;
}
}
| 2,249 |
130,419 | 0 | bool WatchDogThread::PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) {
return PostTaskHelper(from_here, task, delay);
}
| 2,250 |
106,009 | 0 | bool JSTestInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
JSTestInterface* jsTestInterface = jsCast<JSTestInterface*>(handle.get().asCell());
if (jsTestInterface->impl()->hasPendingActivity())
return true;
if (!isObservable(jsTestInterface))
return false;
UNUSED_PARAM(visitor);
return false;
}
| 2,251 |
157,793 | 0 | void WebContentsImpl::IncrementCapturerCount(const gfx::Size& capture_size) {
DCHECK(!is_being_destroyed_);
const bool was_captured = IsBeingCaptured();
++capturer_count_;
DVLOG(1) << "There are now " << capturer_count_
<< " capturing(s) of WebContentsImpl@" << this;
if (!capture_size.IsEmpty() && preferred_size_for_capture_.IsEmpty()) {
preferred_size_for_capture_ = capture_size;
OnPreferredSizeChanged(preferred_size_);
}
if (GetVisibility() != Visibility::VISIBLE && !was_captured) {
for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree())
view->WasUnOccluded();
}
}
| 2,252 |
184,569 | 1 | void GpuVideoDecodeAccelerator::Initialize(
const media::VideoCodecProfile profile,
IPC::Message* init_done_msg,
base::ProcessHandle renderer_process) {
DCHECK(!video_decode_accelerator_.get());
DCHECK(!init_done_msg_);
DCHECK(init_done_msg);
init_done_msg_ = init_done_msg;
#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)) || defined(OS_WIN)
DCHECK(stub_ && stub_->decoder());
#if defined(OS_WIN)
if (base::win::GetVersion() < base::win::VERSION_WIN7) {
NOTIMPLEMENTED() << "HW video decode acceleration not available.";
NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
return;
}
DLOG(INFO) << "Initializing DXVA HW decoder for windows.";
DXVAVideoDecodeAccelerator* video_decoder =
new DXVAVideoDecodeAccelerator(this, renderer_process);
#else // OS_WIN
OmxVideoDecodeAccelerator* video_decoder =
new OmxVideoDecodeAccelerator(this);
video_decoder->SetEglState(
gfx::GLSurfaceEGL::GetHardwareDisplay(),
stub_->decoder()->GetGLContext()->GetHandle());
#endif // OS_WIN
video_decode_accelerator_ = video_decoder;
if (!video_decode_accelerator_->Initialize(profile))
NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
#else // Update RenderViewImpl::createMediaPlayer when adding clauses.
NOTIMPLEMENTED() << "HW video decode acceleration not available.";
NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
}
| 2,253 |
72,116 | 0 | _rpc_job_notify(slurm_msg_t *msg)
{
job_notify_msg_t *req = msg->data;
uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred,
conf->auth_info);
uid_t job_uid;
List steps;
ListIterator i;
step_loc_t *stepd = NULL;
int step_cnt = 0;
int fd;
debug("_rpc_job_notify, uid = %d, jobid = %u", req_uid, req->job_id);
job_uid = _get_job_uid(req->job_id);
if ((int)job_uid < 0)
goto no_job;
/*
* check that requesting user ID is the SLURM UID or root
*/
if ((req_uid != job_uid) && (!_slurm_authorized_user(req_uid))) {
error("Security violation: job_notify(%u) from uid %d",
req->job_id, req_uid);
return;
}
steps = stepd_available(conf->spooldir, conf->node_name);
i = list_iterator_create(steps);
while ((stepd = list_next(i))) {
if ((stepd->jobid != req->job_id) ||
(stepd->stepid != SLURM_BATCH_SCRIPT)) {
continue;
}
step_cnt++;
fd = stepd_connect(stepd->directory, stepd->nodename,
stepd->jobid, stepd->stepid,
&stepd->protocol_version);
if (fd == -1) {
debug3("Unable to connect to step %u.%u",
stepd->jobid, stepd->stepid);
continue;
}
info("send notification to job %u.%u",
stepd->jobid, stepd->stepid);
if (stepd_notify_job(fd, stepd->protocol_version,
req->message) < 0)
debug("notify jobid=%u failed: %m", stepd->jobid);
close(fd);
}
list_iterator_destroy(i);
FREE_NULL_LIST(steps);
no_job:
if (step_cnt == 0) {
debug2("Can't find jobid %u to send notification message",
req->job_id);
}
}
| 2,254 |
120,993 | 0 | void SetOnConnected(
const base::Callback<void(SocketStreamEvent*)>& callback) {
on_connected_ = callback;
}
| 2,255 |
87,762 | 0 | int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key )
{
int ret;
ECDSA_VALIDATE_RET( ctx != NULL );
ECDSA_VALIDATE_RET( key != NULL );
if( ( ret = mbedtls_ecp_group_copy( &ctx->grp, &key->grp ) ) != 0 ||
( ret = mbedtls_mpi_copy( &ctx->d, &key->d ) ) != 0 ||
( ret = mbedtls_ecp_copy( &ctx->Q, &key->Q ) ) != 0 )
{
mbedtls_ecdsa_free( ctx );
}
return( ret );
}
| 2,256 |
652 | 0 | static bool encode_search_options_request(void *mem_ctx, void *in, DATA_BLOB *out)
{
struct ldb_search_options_control *lsoc = talloc_get_type(in, struct ldb_search_options_control);
struct asn1_data *data = asn1_init(mem_ctx);
if (!data) return false;
if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
return false;
}
if (!asn1_write_Integer(data, lsoc->search_options)) {
return false;
}
if (!asn1_pop_tag(data)) {
return false;
}
*out = data_blob_talloc(mem_ctx, data->data, data->length);
if (out->data == NULL) {
return false;
}
talloc_free(data);
return true;
}
| 2,257 |
136,507 | 0 | void PaintController::AddToIndicesByClientMap(const DisplayItemClient& client,
size_t index,
IndicesByClientMap& map) {
auto it = map.find(&client);
auto& indices =
it == map.end()
? map.insert(&client, Vector<size_t>()).stored_value->value
: it->value;
indices.push_back(index);
}
| 2,258 |
186,875 | 1 | void PrintMsg_Print_Params::Reset() {
page_size = gfx::Size();
content_size = gfx::Size();
printable_area = gfx::Rect();
margin_top = 0;
margin_left = 0;
dpi = 0;
scale_factor = 1.0f;
rasterize_pdf = false;
document_cookie = 0;
selection_only = false;
supports_alpha_blend = false;
preview_ui_id = -1;
preview_request_id = 0;
is_first_request = false;
print_scaling_option = blink::kWebPrintScalingOptionSourceSize;
print_to_pdf = false;
display_header_footer = false;
title = base::string16();
url = base::string16();
should_print_backgrounds = false;
printed_doc_type = printing::SkiaDocumentType::PDF;
}
| 2,259 |
94,989 | 0 | ext4_listxattr(struct dentry *dentry, char *buffer, size_t size)
{
return ext4_xattr_list(dentry, buffer, size);
}
| 2,260 |
47,309 | 0 | static int rmd160_init(struct shash_desc *desc)
{
struct rmd160_ctx *rctx = shash_desc_ctx(desc);
rctx->byte_count = 0;
rctx->state[0] = RMD_H0;
rctx->state[1] = RMD_H1;
rctx->state[2] = RMD_H2;
rctx->state[3] = RMD_H3;
rctx->state[4] = RMD_H4;
memset(rctx->buffer, 0, sizeof(rctx->buffer));
return 0;
}
| 2,261 |
158,579 | 0 | void WebLocalFrameImpl::SetName(const WebString& name) {
GetFrame()->Tree().SetName(name, FrameTree::kReplicate);
}
| 2,262 |
145,324 | 0 | void HTMLAnchorElement::defaultEventHandler(Event* event)
{
if (isLink()) {
if (focused() && isEnterKeyKeydownEvent(event) && isLiveLink()) {
event->setDefaultHandled();
dispatchSimulatedClick(event);
return;
}
if (isLinkClick(event) && isLiveLink()) {
handleClick(event);
return;
}
}
HTMLElement::defaultEventHandler(event);
}
| 2,263 |
138,072 | 0 | bool AXNodeObject::isMenu() const {
return roleValue() == MenuRole;
}
| 2,264 |
154,012 | 0 | void GLES2DecoderImpl::DoGetIntegeri_v(GLenum target,
GLuint index,
GLint* params,
GLsizei params_size) {
GetIndexedIntegerImpl<GLint>("glGetIntegeri_v", target, index, params);
}
| 2,265 |
125,162 | 0 | MockPluginProcessHostClient(ResourceContext* context, bool expect_fail)
: context_(context),
channel_(NULL),
set_plugin_info_called_(false),
expect_fail_(expect_fail) {
}
| 2,266 |
137,485 | 0 | base::Closure RunLoop::QuitClosure() {
return base::Bind(&ProxyToTaskRunner, origin_task_runner_,
base::Bind(&RunLoop::Quit, weak_factory_.GetWeakPtr()));
}
| 2,267 |
151,011 | 0 | void DevToolsUIBindings::LoadNetworkResource(const DispatchCallback& callback,
const std::string& url,
const std::string& headers,
int stream_id) {
GURL gurl(url);
if (!gurl.is_valid()) {
base::DictionaryValue response;
response.SetInteger("statusCode", 404);
callback.Run(&response);
return;
}
net::URLFetcher* fetcher =
net::URLFetcher::Create(gurl, net::URLFetcher::GET, this).release();
pending_requests_[fetcher] = callback;
fetcher->SetRequestContext(profile_->GetRequestContext());
fetcher->SetExtraRequestHeaders(headers);
fetcher->SaveResponseWithWriter(
std::unique_ptr<net::URLFetcherResponseWriter>(
new ResponseWriter(weak_factory_.GetWeakPtr(), stream_id)));
fetcher->Start();
}
| 2,268 |
87,236 | 0 | hfs_cat_get_record_offset_cb(HFS_INFO * hfs, int8_t level_type,
const hfs_btree_key_cat * cur_key,
TSK_OFF_T key_off, void *ptr)
{
HFS_CAT_GET_RECORD_OFFSET_DATA *offset_data = (HFS_CAT_GET_RECORD_OFFSET_DATA *)ptr;
const hfs_btree_key_cat *targ_key = offset_data->targ_key;
if (tsk_verbose)
tsk_fprintf(stderr,
"hfs_cat_get_record_offset_cb: %s node want: %" PRIu32
" vs have: %" PRIu32 "\n",
(level_type == HFS_BT_NODE_TYPE_IDX) ? "Index" : "Leaf",
tsk_getu32(hfs->fs_info.endian, targ_key->parent_cnid),
tsk_getu32(hfs->fs_info.endian, cur_key->parent_cnid));
if (level_type == HFS_BT_NODE_TYPE_IDX) {
int diff = hfs_cat_compare_keys(hfs, cur_key, targ_key);
if (diff < 0)
return HFS_BTREE_CB_IDX_LT;
else
return HFS_BTREE_CB_IDX_EQGT;
}
else {
int diff = hfs_cat_compare_keys(hfs, cur_key, targ_key);
if (diff < 0) {
return HFS_BTREE_CB_LEAF_GO;
}
else if (diff == 0) {
offset_data->off =
key_off + 2 + tsk_getu16(hfs->fs_info.endian,
cur_key->key_len);
}
return HFS_BTREE_CB_LEAF_STOP;
}
}
| 2,269 |
105,077 | 0 | bool running() const { return running_; }
| 2,270 |
143,021 | 0 | void BaseAudioContext::ReleaseActiveSourceNodes() {
DCHECK(IsMainThread());
for (auto& source_node : active_source_nodes_)
source_node->Handler().BreakConnection();
active_source_nodes_.clear();
}
| 2,271 |
112,760 | 0 | void PrintPreviewHandler::HandleShowSystemDialog(const ListValue* /*args*/) {
ReportStats();
ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG);
TabContents* initiator_tab = GetInitiatorTab();
if (!initiator_tab)
return;
printing::PrintViewManager* manager = initiator_tab->print_view_manager();
manager->set_observer(this);
manager->PrintForSystemDialogNow();
PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
web_ui()->GetController());
print_preview_ui->OnCancelPendingPreviewRequest();
}
| 2,272 |
76,920 | 0 | format_DEBUG_RECIRC(const struct ofpact_null *a OVS_UNUSED, struct ds *s)
{
ds_put_format(s, "%sdebug_recirc%s", colors.value, colors.end);
}
| 2,273 |
29,571 | 0 | int ipc_parse_version (int *cmd)
{
if (*cmd & IPC_64) {
*cmd ^= IPC_64;
return IPC_64;
} else {
return IPC_OLD;
}
}
| 2,274 |
176,901 | 0 | bool InputDispatcher::afterMotionEventLockedInterruptible(const sp<Connection>& connection,
DispatchEntry* dispatchEntry, MotionEntry* motionEntry, bool handled) {
return false;
}
| 2,275 |
79,450 | 0 | static void write_matrix(AVIOContext *pb, int16_t a, int16_t b, int16_t c,
int16_t d, int16_t tx, int16_t ty)
{
avio_wb32(pb, a << 16); /* 16.16 format */
avio_wb32(pb, b << 16); /* 16.16 format */
avio_wb32(pb, 0); /* u in 2.30 format */
avio_wb32(pb, c << 16); /* 16.16 format */
avio_wb32(pb, d << 16); /* 16.16 format */
avio_wb32(pb, 0); /* v in 2.30 format */
avio_wb32(pb, tx << 16); /* 16.16 format */
avio_wb32(pb, ty << 16); /* 16.16 format */
avio_wb32(pb, 1 << 30); /* w in 2.30 format */
}
| 2,276 |
143,213 | 0 | bool Document::isInInvisibleSubframe() const
{
if (!localOwner())
return false; // this is a local root element
DCHECK(frame());
return !frame()->ownerLayoutObject();
}
| 2,277 |
146,952 | 0 | void WebLocalFrameImpl::DeleteSurroundingTextInCodePoints(int before,
int after) {
TRACE_EVENT0("blink", "WebLocalFrameImpl::deleteSurroundingTextInCodePoints");
if (WebPlugin* plugin = FocusedPluginIfInputMethodSupported()) {
plugin->DeleteSurroundingTextInCodePoints(before, after);
return;
}
GetFrame()->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
GetFrame()->GetInputMethodController().DeleteSurroundingTextInCodePoints(
before, after);
}
| 2,278 |
128,578 | 0 | std::vector<pp::ImageData> Instance::GetThumbnailResources() {
std::vector<pp::ImageData> num_images(10);
num_images[0] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_0);
num_images[1] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_1);
num_images[2] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_2);
num_images[3] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_3);
num_images[4] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_4);
num_images[5] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_5);
num_images[6] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_6);
num_images[7] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_7);
num_images[8] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_8);
num_images[9] = CreateResourceImage(PP_RESOURCEIMAGE_PDF_BUTTON_THUMBNAIL_9);
return num_images;
}
| 2,279 |
90,201 | 0 | static void rds_tcp_tc_info(struct socket *rds_sock, unsigned int len,
struct rds_info_iterator *iter,
struct rds_info_lengths *lens)
{
struct rds_info_tcp_socket tsinfo;
struct rds_tcp_connection *tc;
unsigned long flags;
spin_lock_irqsave(&rds_tcp_tc_list_lock, flags);
if (len / sizeof(tsinfo) < rds_tcp_tc_count)
goto out;
list_for_each_entry(tc, &rds_tcp_tc_list, t_list_item) {
struct inet_sock *inet = inet_sk(tc->t_sock->sk);
if (tc->t_cpath->cp_conn->c_isv6)
continue;
tsinfo.local_addr = inet->inet_saddr;
tsinfo.local_port = inet->inet_sport;
tsinfo.peer_addr = inet->inet_daddr;
tsinfo.peer_port = inet->inet_dport;
tsinfo.hdr_rem = tc->t_tinc_hdr_rem;
tsinfo.data_rem = tc->t_tinc_data_rem;
tsinfo.last_sent_nxt = tc->t_last_sent_nxt;
tsinfo.last_expected_una = tc->t_last_expected_una;
tsinfo.last_seen_una = tc->t_last_seen_una;
tsinfo.tos = tc->t_cpath->cp_conn->c_tos;
rds_info_copy(iter, &tsinfo, sizeof(tsinfo));
}
out:
lens->nr = rds_tcp_tc_count;
lens->each = sizeof(tsinfo);
spin_unlock_irqrestore(&rds_tcp_tc_list_lock, flags);
}
| 2,280 |
91,270 | 0 | static struct bmc_device *ipmi_find_bmc_guid(struct device_driver *drv,
guid_t *guid)
{
struct device *dev;
struct bmc_device *bmc = NULL;
dev = driver_find_device(drv, NULL, guid, __find_bmc_guid);
if (dev) {
bmc = to_bmc_device(dev);
put_device(dev);
}
return bmc;
}
| 2,281 |
158,548 | 0 | void WebLocalFrameImpl::InitializeCoreFrame(Page& page,
FrameOwner* owner,
const AtomicString& name) {
SetCoreFrame(LocalFrame::Create(local_frame_client_.Get(), page, owner,
interface_registry_));
frame_->Tree().SetName(name);
frame_->Init();
CHECK(frame_);
CHECK(frame_->Loader().StateMachine()->IsDisplayingInitialEmptyDocument());
if (!Parent() && !Opener() &&
frame_->GetSettings()->GetShouldReuseGlobalForUnownedMainFrame()) {
frame_->GetDocument()->GetMutableSecurityOrigin()->GrantUniversalAccess();
}
if (frame_->IsLocalRoot()) {
frame_->GetInterfaceRegistry()->AddAssociatedInterface(
WTF::BindRepeating(&WebLocalFrameImpl::BindDevToolsAgentRequest,
WrapWeakPersistent(this)));
}
if (!owner) {
TRACE_EVENT_INSTANT1("loading", "markAsMainFrame", TRACE_EVENT_SCOPE_THREAD,
"frame", ToTraceValue(frame_));
}
}
| 2,282 |
185,907 | 1 | void OffscreenCanvasFrameReceiverImpl::SubmitCompositorFrame(
const cc::SurfaceId& surface_id,
cc::CompositorFrame frame) {
cc::Surface* surface = GetSurfaceManager()->GetSurfaceForId(surface_id);
if (surface) {
surface->QueueFrame(std::move(frame), base::Closure());
}
// If surface doet not exist, drop the frame.
}
| 2,283 |
135,240 | 0 | EventQueue* Document::eventQueue() const
{
if (!m_domWindow)
return 0;
return m_domWindow->eventQueue();
}
| 2,284 |
123,399 | 0 | void RenderWidgetHostViewGuest::SetIsLoading(bool is_loading) {
NOTIMPLEMENTED();
}
| 2,285 |
183,369 | 1 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info,
const int argc,const char **argv,Image **images,ExceptionInfo *exception)
{
const char
*option;
ImageInfo
*mogrify_info;
MagickStatusType
status;
PixelInterpolateMethod
interpolate_method;
QuantizeInfo
*quantize_info;
register ssize_t
i;
ssize_t
count,
index;
/*
Apply options to the image list.
*/
assert(image_info != (ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
assert(images != (Image **) NULL);
assert((*images)->previous == (Image *) NULL);
assert((*images)->signature == MagickCoreSignature);
if ((*images)->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
(*images)->filename);
if ((argc <= 0) || (*argv == (char *) NULL))
return(MagickTrue);
interpolate_method=UndefinedInterpolatePixel;
mogrify_info=CloneImageInfo(image_info);
quantize_info=AcquireQuantizeInfo(mogrify_info);
status=MagickTrue;
for (i=0; i < (ssize_t) argc; i++)
{
if (*images == (Image *) NULL)
break;
option=argv[i];
if (IsCommandOption(option) == MagickFalse)
continue;
count=ParseCommandOption(MagickCommandOptions,MagickFalse,option);
count=MagickMax(count,0L);
if ((i+count) >= (ssize_t) argc)
break;
status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception);
switch (*(option+1))
{
case 'a':
{
if (LocaleCompare("affinity",option+1) == 0)
{
(void) SyncImagesSettings(mogrify_info,*images,exception);
if (*option == '+')
{
(void) RemapImages(quantize_info,*images,(Image *) NULL,
exception);
break;
}
i++;
break;
}
if (LocaleCompare("append",option+1) == 0)
{
Image
*append_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
append_image=AppendImages(*images,*option == '-' ? MagickTrue :
MagickFalse,exception);
if (append_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=append_image;
break;
}
if (LocaleCompare("average",option+1) == 0)
{
Image
*average_image;
/*
Average an image sequence (deprecated).
*/
(void) SyncImagesSettings(mogrify_info,*images,exception);
average_image=EvaluateImages(*images,MeanEvaluateOperator,
exception);
if (average_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=average_image;
break;
}
break;
}
case 'c':
{
if (LocaleCompare("channel-fx",option+1) == 0)
{
Image
*channel_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
channel_image=ChannelFxImage(*images,argv[i+1],exception);
if (channel_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=channel_image;
break;
}
if (LocaleCompare("clut",option+1) == 0)
{
Image
*clut_image,
*image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
image=RemoveFirstImageFromList(images);
clut_image=RemoveFirstImageFromList(images);
if (clut_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
(void) ClutImage(image,clut_image,interpolate_method,exception);
clut_image=DestroyImage(clut_image);
*images=DestroyImageList(*images);
*images=image;
break;
}
if (LocaleCompare("coalesce",option+1) == 0)
{
Image
*coalesce_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
coalesce_image=CoalesceImages(*images,exception);
if (coalesce_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=coalesce_image;
break;
}
if (LocaleCompare("combine",option+1) == 0)
{
ColorspaceType
colorspace;
Image
*combine_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
colorspace=(*images)->colorspace;
if ((*images)->number_channels < GetImageListLength(*images))
colorspace=sRGBColorspace;
if (*option == '+')
colorspace=(ColorspaceType) ParseCommandOption(
MagickColorspaceOptions,MagickFalse,argv[i+1]);
combine_image=CombineImages(*images,colorspace,exception);
if (combine_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=combine_image;
break;
}
if (LocaleCompare("compare",option+1) == 0)
{
double
distortion;
Image
*difference_image,
*image,
*reconstruct_image;
MetricType
metric;
/*
Mathematically and visually annotate the difference between an
image and its reconstruction.
*/
(void) SyncImagesSettings(mogrify_info,*images,exception);
image=RemoveFirstImageFromList(images);
reconstruct_image=RemoveFirstImageFromList(images);
if (reconstruct_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
metric=UndefinedErrorMetric;
option=GetImageOption(mogrify_info,"metric");
if (option != (const char *) NULL)
metric=(MetricType) ParseCommandOption(MagickMetricOptions,
MagickFalse,option);
difference_image=CompareImages(image,reconstruct_image,metric,
&distortion,exception);
if (difference_image == (Image *) NULL)
break;
if (*images != (Image *) NULL)
*images=DestroyImageList(*images);
*images=difference_image;
break;
}
if (LocaleCompare("complex",option+1) == 0)
{
ComplexOperator
op;
Image
*complex_images;
(void) SyncImageSettings(mogrify_info,*images,exception);
op=(ComplexOperator) ParseCommandOption(MagickComplexOptions,
MagickFalse,argv[i+1]);
complex_images=ComplexImages(*images,op,exception);
if (complex_images == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=complex_images;
break;
}
if (LocaleCompare("composite",option+1) == 0)
{
CompositeOperator
compose;
const char*
value;
MagickBooleanType
clip_to_self;
Image
*mask_image,
*new_images,
*source_image;
RectangleInfo
geometry;
/* Compose value from "-compose" option only */
(void) SyncImageSettings(mogrify_info,*images,exception);
value=GetImageOption(mogrify_info,"compose");
if (value == (const char *) NULL)
compose=OverCompositeOp; /* use Over not source_image->compose */
else
compose=(CompositeOperator) ParseCommandOption(
MagickComposeOptions,MagickFalse,value);
/* Get "clip-to-self" expert setting (false is normal) */
clip_to_self=GetCompositeClipToSelf(compose);
value=GetImageOption(mogrify_info,"compose:clip-to-self");
if (value != (const char *) NULL)
clip_to_self=IsStringTrue(value);
value=GetImageOption(mogrify_info,"compose:outside-overlay");
if (value != (const char *) NULL)
clip_to_self=IsStringFalse(value); /* deprecated */
new_images=RemoveFirstImageFromList(images);
source_image=RemoveFirstImageFromList(images);
if (source_image == (Image *) NULL)
break; /* FUTURE - produce Exception, rather than silent fail */
/* FUTURE: this should not be here! - should be part of -geometry */
if (source_image->geometry != (char *) NULL)
{
RectangleInfo
resize_geometry;
(void) ParseRegionGeometry(source_image,source_image->geometry,
&resize_geometry,exception);
if ((source_image->columns != resize_geometry.width) ||
(source_image->rows != resize_geometry.height))
{
Image
*resize_image;
resize_image=ResizeImage(source_image,resize_geometry.width,
resize_geometry.height,source_image->filter,exception);
if (resize_image != (Image *) NULL)
{
source_image=DestroyImage(source_image);
source_image=resize_image;
}
}
}
SetGeometry(source_image,&geometry);
(void) ParseAbsoluteGeometry(source_image->geometry,&geometry);
GravityAdjustGeometry(new_images->columns,new_images->rows,
new_images->gravity,&geometry);
mask_image=RemoveFirstImageFromList(images);
if (mask_image == (Image *) NULL)
status&=CompositeImage(new_images,source_image,compose,
clip_to_self,geometry.x,geometry.y,exception);
else
{
if ((compose == DisplaceCompositeOp) ||
(compose == DistortCompositeOp))
{
status&=CompositeImage(source_image,mask_image,
CopyGreenCompositeOp,MagickTrue,0,0,exception);
status&=CompositeImage(new_images,source_image,compose,
clip_to_self,geometry.x,geometry.y,exception);
}
else
{
Image
*clone_image;
clone_image=CloneImage(new_images,0,0,MagickTrue,exception);
if (clone_image == (Image *) NULL)
break;
status&=CompositeImage(new_images,source_image,compose,
clip_to_self,geometry.x,geometry.y,exception);
status&=CompositeImage(new_images,mask_image,
CopyAlphaCompositeOp,MagickTrue,0,0,exception);
status&=CompositeImage(clone_image,new_images,
OverCompositeOp,clip_to_self,0,0,exception);
new_images=DestroyImageList(new_images);
new_images=clone_image;
}
mask_image=DestroyImage(mask_image);
}
source_image=DestroyImage(source_image);
*images=DestroyImageList(*images);
*images=new_images;
break;
}
if (LocaleCompare("copy",option+1) == 0)
{
Image
*source_image;
OffsetInfo
offset;
RectangleInfo
geometry;
/*
Copy image pixels.
*/
(void) SyncImageSettings(mogrify_info,*images,exception);
(void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
offset.x=geometry.x;
offset.y=geometry.y;
source_image=(*images);
if (source_image->next != (Image *) NULL)
source_image=source_image->next;
(void) ParsePageGeometry(source_image,argv[i+1],&geometry,
exception);
status=CopyImagePixels(*images,source_image,&geometry,&offset,
exception);
break;
}
break;
}
case 'd':
{
if (LocaleCompare("deconstruct",option+1) == 0)
{
Image
*deconstruct_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer,
exception);
if (deconstruct_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=deconstruct_image;
break;
}
if (LocaleCompare("delete",option+1) == 0)
{
if (*option == '+')
DeleteImages(images,"-1",exception);
else
DeleteImages(images,argv[i+1],exception);
break;
}
if (LocaleCompare("dither",option+1) == 0)
{
if (*option == '+')
{
quantize_info->dither_method=NoDitherMethod;
break;
}
quantize_info->dither_method=(DitherMethod) ParseCommandOption(
MagickDitherOptions,MagickFalse,argv[i+1]);
break;
}
if (LocaleCompare("duplicate",option+1) == 0)
{
Image
*duplicate_images;
if (*option == '+')
duplicate_images=DuplicateImages(*images,1,"-1",exception);
else
{
const char
*p;
size_t
number_duplicates;
number_duplicates=(size_t) StringToLong(argv[i+1]);
p=strchr(argv[i+1],',');
if (p == (const char *) NULL)
duplicate_images=DuplicateImages(*images,number_duplicates,
"-1",exception);
else
duplicate_images=DuplicateImages(*images,number_duplicates,p,
exception);
}
AppendImageToList(images, duplicate_images);
(void) SyncImagesSettings(mogrify_info,*images,exception);
break;
}
break;
}
case 'e':
{
if (LocaleCompare("evaluate-sequence",option+1) == 0)
{
Image
*evaluate_image;
MagickEvaluateOperator
op;
(void) SyncImageSettings(mogrify_info,*images,exception);
op=(MagickEvaluateOperator) ParseCommandOption(
MagickEvaluateOptions,MagickFalse,argv[i+1]);
evaluate_image=EvaluateImages(*images,op,exception);
if (evaluate_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=evaluate_image;
break;
}
break;
}
case 'f':
{
if (LocaleCompare("fft",option+1) == 0)
{
Image
*fourier_image;
/*
Implements the discrete Fourier transform (DFT).
*/
(void) SyncImageSettings(mogrify_info,*images,exception);
fourier_image=ForwardFourierTransformImage(*images,*option == '-' ?
MagickTrue : MagickFalse,exception);
if (fourier_image == (Image *) NULL)
break;
*images=DestroyImageList(*images);
*images=fourier_image;
break;
}
if (LocaleCompare("flatten",option+1) == 0)
{
Image
*flatten_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
flatten_image=MergeImageLayers(*images,FlattenLayer,exception);
if (flatten_image == (Image *) NULL)
break;
*images=DestroyImageList(*images);
*images=flatten_image;
break;
}
if (LocaleCompare("fx",option+1) == 0)
{
Image
*fx_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
fx_image=FxImage(*images,argv[i+1],exception);
if (fx_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=fx_image;
break;
}
break;
}
case 'h':
{
if (LocaleCompare("hald-clut",option+1) == 0)
{
Image
*hald_image,
*image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
image=RemoveFirstImageFromList(images);
hald_image=RemoveFirstImageFromList(images);
if (hald_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
(void) HaldClutImage(image,hald_image,exception);
hald_image=DestroyImage(hald_image);
if (*images != (Image *) NULL)
*images=DestroyImageList(*images);
*images=image;
break;
}
break;
}
case 'i':
{
if (LocaleCompare("ift",option+1) == 0)
{
Image
*fourier_image,
*magnitude_image,
*phase_image;
/*
Implements the inverse fourier discrete Fourier transform (DFT).
*/
(void) SyncImagesSettings(mogrify_info,*images,exception);
magnitude_image=RemoveFirstImageFromList(images);
phase_image=RemoveFirstImageFromList(images);
if (phase_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
fourier_image=InverseFourierTransformImage(magnitude_image,
phase_image,*option == '-' ? MagickTrue : MagickFalse,exception);
if (fourier_image == (Image *) NULL)
break;
if (*images != (Image *) NULL)
*images=DestroyImageList(*images);
*images=fourier_image;
break;
}
if (LocaleCompare("insert",option+1) == 0)
{
Image
*p,
*q;
index=0;
if (*option != '+')
index=(ssize_t) StringToLong(argv[i+1]);
p=RemoveLastImageFromList(images);
if (p == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionError,"NoSuchImage","`%s'",argv[i+1]);
status=MagickFalse;
break;
}
q=p;
if (index == 0)
PrependImageToList(images,q);
else
if (index == (ssize_t) GetImageListLength(*images))
AppendImageToList(images,q);
else
{
q=GetImageFromList(*images,index-1);
if (q == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionError,"NoSuchImage","`%s'",argv[i+1]);
status=MagickFalse;
break;
}
InsertImageInList(&q,p);
}
*images=GetFirstImageInList(q);
break;
}
if (LocaleCompare("interpolate",option+1) == 0)
{
interpolate_method=(PixelInterpolateMethod) ParseCommandOption(
MagickInterpolateOptions,MagickFalse,argv[i+1]);
break;
}
break;
}
case 'l':
{
if (LocaleCompare("layers",option+1) == 0)
{
Image
*layers;
LayerMethod
method;
(void) SyncImagesSettings(mogrify_info,*images,exception);
layers=(Image *) NULL;
method=(LayerMethod) ParseCommandOption(MagickLayerOptions,
MagickFalse,argv[i+1]);
switch (method)
{
case CoalesceLayer:
{
layers=CoalesceImages(*images,exception);
break;
}
case CompareAnyLayer:
case CompareClearLayer:
case CompareOverlayLayer:
default:
{
layers=CompareImagesLayers(*images,method,exception);
break;
}
case MergeLayer:
case FlattenLayer:
case MosaicLayer:
case TrimBoundsLayer:
{
layers=MergeImageLayers(*images,method,exception);
break;
}
case DisposeLayer:
{
layers=DisposeImages(*images,exception);
break;
}
case OptimizeImageLayer:
{
layers=OptimizeImageLayers(*images,exception);
break;
}
case OptimizePlusLayer:
{
layers=OptimizePlusImageLayers(*images,exception);
break;
}
case OptimizeTransLayer:
{
OptimizeImageTransparency(*images,exception);
break;
}
case RemoveDupsLayer:
{
RemoveDuplicateLayers(images,exception);
break;
}
case RemoveZeroLayer:
{
RemoveZeroDelayLayers(images,exception);
break;
}
case OptimizeLayer:
{
/*
General Purpose, GIF Animation Optimizer.
*/
layers=CoalesceImages(*images,exception);
if (layers == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=layers;
layers=OptimizeImageLayers(*images,exception);
if (layers == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=layers;
layers=(Image *) NULL;
OptimizeImageTransparency(*images,exception);
(void) RemapImages(quantize_info,*images,(Image *) NULL,
exception);
break;
}
case CompositeLayer:
{
CompositeOperator
compose;
Image
*source;
RectangleInfo
geometry;
/*
Split image sequence at the first 'NULL:' image.
*/
source=(*images);
while (source != (Image *) NULL)
{
source=GetNextImageInList(source);
if ((source != (Image *) NULL) &&
(LocaleCompare(source->magick,"NULL") == 0))
break;
}
if (source != (Image *) NULL)
{
if ((GetPreviousImageInList(source) == (Image *) NULL) ||
(GetNextImageInList(source) == (Image *) NULL))
source=(Image *) NULL;
else
{
/*
Separate the two lists, junk the null: image.
*/
source=SplitImageList(source->previous);
DeleteImageFromList(&source);
}
}
if (source == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionError,"MissingNullSeparator","layers Composite");
status=MagickFalse;
break;
}
/*
Adjust offset with gravity and virtual canvas.
*/
SetGeometry(*images,&geometry);
(void) ParseAbsoluteGeometry((*images)->geometry,&geometry);
geometry.width=source->page.width != 0 ?
source->page.width : source->columns;
geometry.height=source->page.height != 0 ?
source->page.height : source->rows;
GravityAdjustGeometry((*images)->page.width != 0 ?
(*images)->page.width : (*images)->columns,
(*images)->page.height != 0 ? (*images)->page.height :
(*images)->rows,(*images)->gravity,&geometry);
compose=OverCompositeOp;
option=GetImageOption(mogrify_info,"compose");
if (option != (const char *) NULL)
compose=(CompositeOperator) ParseCommandOption(
MagickComposeOptions,MagickFalse,option);
CompositeLayers(*images,compose,source,geometry.x,geometry.y,
exception);
source=DestroyImageList(source);
break;
}
}
if (layers == (Image *) NULL)
break;
*images=DestroyImageList(*images);
*images=layers;
break;
}
break;
}
case 'm':
{
if (LocaleCompare("map",option+1) == 0)
{
(void) SyncImagesSettings(mogrify_info,*images,exception);
if (*option == '+')
{
(void) RemapImages(quantize_info,*images,(Image *) NULL,
exception);
break;
}
i++;
break;
}
if (LocaleCompare("maximum",option+1) == 0)
{
Image
*maximum_image;
/*
Maximum image sequence (deprecated).
*/
(void) SyncImagesSettings(mogrify_info,*images,exception);
maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception);
if (maximum_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=maximum_image;
break;
}
if (LocaleCompare("minimum",option+1) == 0)
{
Image
*minimum_image;
/*
Minimum image sequence (deprecated).
*/
(void) SyncImagesSettings(mogrify_info,*images,exception);
minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception);
if (minimum_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=minimum_image;
break;
}
if (LocaleCompare("morph",option+1) == 0)
{
Image
*morph_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]),
exception);
if (morph_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=morph_image;
break;
}
if (LocaleCompare("mosaic",option+1) == 0)
{
Image
*mosaic_image;
(void) SyncImagesSettings(mogrify_info,*images,exception);
mosaic_image=MergeImageLayers(*images,MosaicLayer,exception);
if (mosaic_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=mosaic_image;
break;
}
break;
}
case 'p':
{
if (LocaleCompare("poly",option+1) == 0)
{
char
*args,
token[MagickPathExtent];
const char
*p;
double
*arguments;
Image
*polynomial_image;
register ssize_t
x;
size_t
number_arguments;
/*
Polynomial image.
*/
(void) SyncImageSettings(mogrify_info,*images,exception);
args=InterpretImageProperties(mogrify_info,*images,argv[i+1],
exception);
if (args == (char *) NULL)
break;
p=(char *) args;
for (x=0; *p != '\0'; x++)
{
GetNextToken(p,&p,MagickPathExtent,token);
if (*token == ',')
GetNextToken(p,&p,MagickPathExtent,token);
}
number_arguments=(size_t) x;
arguments=(double *) AcquireQuantumMemory(number_arguments,
sizeof(*arguments));
if (arguments == (double *) NULL)
ThrowWandFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",(*images)->filename);
(void) memset(arguments,0,number_arguments*
sizeof(*arguments));
p=(char *) args;
for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++)
{
GetNextToken(p,&p,MagickPathExtent,token);
if (*token == ',')
GetNextToken(p,&p,MagickPathExtent,token);
arguments[x]=StringToDouble(token,(char **) NULL);
}
args=DestroyString(args);
polynomial_image=PolynomialImage(*images,number_arguments >> 1,
arguments,exception);
arguments=(double *) RelinquishMagickMemory(arguments);
if (polynomial_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=polynomial_image;
}
if (LocaleCompare("print",option+1) == 0)
{
char
*string;
(void) SyncImagesSettings(mogrify_info,*images,exception);
string=InterpretImageProperties(mogrify_info,*images,argv[i+1],
exception);
if (string == (char *) NULL)
break;
(void) FormatLocaleFile(stdout,"%s",string);
string=DestroyString(string);
}
if (LocaleCompare("process",option+1) == 0)
{
char
**arguments;
int
j,
number_arguments;
(void) SyncImagesSettings(mogrify_info,*images,exception);
arguments=StringToArgv(argv[i+1],&number_arguments);
if (arguments == (char **) NULL)
break;
if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL))
{
char
breaker,
quote,
*token;
const char
*argument;
int
next,
token_status;
size_t
length;
TokenInfo
*token_info;
/*
Support old style syntax, filter="-option arg".
*/
length=strlen(argv[i+1]);
token=(char *) NULL;
if (~length >= (MagickPathExtent-1))
token=(char *) AcquireQuantumMemory(length+MagickPathExtent,
sizeof(*token));
if (token == (char *) NULL)
break;
next=0;
argument=argv[i+1];
token_info=AcquireTokenInfo();
token_status=Tokenizer(token_info,0,token,length,argument,"",
"=","\"",'\0',&breaker,&next,"e);
token_info=DestroyTokenInfo(token_info);
if (token_status == 0)
{
const char
*arg;
arg=(&(argument[next]));
(void) InvokeDynamicImageFilter(token,&(*images),1,&arg,
exception);
}
token=DestroyString(token);
break;
}
(void) SubstituteString(&arguments[1],"-","");
(void) InvokeDynamicImageFilter(arguments[1],&(*images),
number_arguments-2,(const char **) arguments+2,exception);
for (j=0; j < number_arguments; j++)
arguments[j]=DestroyString(arguments[j]);
arguments=(char **) RelinquishMagickMemory(arguments);
break;
}
break;
}
case 'r':
{
if (LocaleCompare("reverse",option+1) == 0)
{
ReverseImageList(images);
break;
}
break;
}
case 's':
{
if (LocaleCompare("smush",option+1) == 0)
{
Image
*smush_image;
ssize_t
offset;
(void) SyncImagesSettings(mogrify_info,*images,exception);
offset=(ssize_t) StringToLong(argv[i+1]);
smush_image=SmushImages(*images,*option == '-' ? MagickTrue :
MagickFalse,offset,exception);
if (smush_image == (Image *) NULL)
{
status=MagickFalse;
break;
}
*images=DestroyImageList(*images);
*images=smush_image;
break;
}
if (LocaleCompare("swap",option+1) == 0)
{
Image
*p,
*q,
*u,
*v;
ssize_t
swap_index;
index=(-1);
swap_index=(-2);
if (*option != '+')
{
GeometryInfo
geometry_info;
MagickStatusType
flags;
swap_index=(-1);
flags=ParseGeometry(argv[i+1],&geometry_info);
index=(ssize_t) geometry_info.rho;
if ((flags & SigmaValue) != 0)
swap_index=(ssize_t) geometry_info.sigma;
}
p=GetImageFromList(*images,index);
q=GetImageFromList(*images,swap_index);
if ((p == (Image *) NULL) || (q == (Image *) NULL))
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionError,"NoSuchImage","`%s'",(*images)->filename);
status=MagickFalse;
break;
}
if (p == q)
break;
u=CloneImage(p,0,0,MagickTrue,exception);
if (u == (Image *) NULL)
break;
v=CloneImage(q,0,0,MagickTrue,exception);
if (v == (Image *) NULL)
{
u=DestroyImage(u);
break;
}
ReplaceImageInList(&p,v);
ReplaceImageInList(&q,u);
*images=GetFirstImageInList(q);
break;
}
break;
}
case 'w':
{
if (LocaleCompare("write",option+1) == 0)
{
char
key[MagickPathExtent];
Image
*write_images;
ImageInfo
*write_info;
(void) SyncImagesSettings(mogrify_info,*images,exception);
(void) FormatLocaleString(key,MagickPathExtent,"cache:%s",
argv[i+1]);
(void) DeleteImageRegistry(key);
write_images=(*images);
if (*option == '+')
write_images=CloneImageList(*images,exception);
write_info=CloneImageInfo(mogrify_info);
status&=WriteImages(write_info,write_images,argv[i+1],exception);
write_info=DestroyImageInfo(write_info);
if (*option == '+')
write_images=DestroyImageList(write_images);
break;
}
break;
}
default:
break;
}
i+=count;
}
quantize_info=DestroyQuantizeInfo(quantize_info);
mogrify_info=DestroyImageInfo(mogrify_info);
status&=MogrifyImageInfo(image_info,argc,argv,exception);
return(status != 0 ? MagickTrue : MagickFalse);
}
| 2,286 |
20,327 | 0 | int is_fault_pfn(pfn_t pfn)
{
return pfn == fault_pfn;
}
| 2,287 |
2,806 | 0 | gx_device_free_local(gx_device *dev)
{
gx_device_finalize(dev->memory, dev);
}
| 2,288 |
95,590 | 0 | void QDECL Com_Error( int code, const char *fmt, ... ) {
va_list argptr;
static int lastErrorTime;
static int errorCount;
int currentTime;
qboolean restartClient;
if(com_errorEntered)
Sys_Error("recursive error after: %s", com_errorMessage);
com_errorEntered = qtrue;
Cvar_Set("com_errorCode", va("%i", code));
if ( com_buildScript && com_buildScript->integer ) {
code = ERR_FATAL;
}
currentTime = Sys_Milliseconds();
if ( currentTime - lastErrorTime < 100 ) {
if ( ++errorCount > 3 ) {
code = ERR_FATAL;
}
} else {
errorCount = 0;
}
lastErrorTime = currentTime;
va_start( argptr,fmt );
Q_vsnprintf (com_errorMessage, sizeof(com_errorMessage),fmt,argptr);
va_end( argptr );
if (code != ERR_DISCONNECT && code != ERR_NEED_CD)
Cvar_Set( "com_errorMessage", com_errorMessage );
restartClient = com_gameClientRestarting && !( com_cl_running && com_cl_running->integer );
com_gameRestarting = qfalse;
com_gameClientRestarting = qfalse;
if (code == ERR_DISCONNECT || code == ERR_SERVERDISCONNECT) {
VM_Forced_Unload_Start();
SV_Shutdown( "Server disconnected" );
if ( restartClient ) {
CL_Init();
}
CL_Disconnect( qtrue );
CL_FlushMemory();
VM_Forced_Unload_Done();
FS_PureServerSetLoadedPaks("", "");
com_errorEntered = qfalse;
longjmp( abortframe, -1 );
} else if (code == ERR_DROP) {
Com_Printf( "********************\nERROR: %s\n********************\n", com_errorMessage );
VM_Forced_Unload_Start();
SV_Shutdown (va("Server crashed: %s", com_errorMessage));
if ( restartClient ) {
CL_Init();
}
CL_Disconnect( qtrue );
CL_FlushMemory();
VM_Forced_Unload_Done();
FS_PureServerSetLoadedPaks("", "");
com_errorEntered = qfalse;
longjmp( abortframe, -1 );
} else if ( code == ERR_NEED_CD ) {
VM_Forced_Unload_Start();
SV_Shutdown( "Server didn't have CD" );
if ( restartClient ) {
CL_Init();
}
if ( com_cl_running && com_cl_running->integer ) {
CL_Disconnect( qtrue );
CL_FlushMemory();
VM_Forced_Unload_Done();
CL_CDDialog();
} else {
Com_Printf( "Server didn't have CD\n" );
VM_Forced_Unload_Done();
}
FS_PureServerSetLoadedPaks("", "");
com_errorEntered = qfalse;
longjmp( abortframe, -1 );
} else {
VM_Forced_Unload_Start();
CL_Shutdown(va("Client fatal crashed: %s", com_errorMessage), qtrue, qtrue);
SV_Shutdown(va("Server fatal crashed: %s", com_errorMessage));
VM_Forced_Unload_Done();
}
Com_Shutdown();
Sys_Error( "%s", com_errorMessage );
}
| 2,289 |
74,297 | 0 | int read_fs_bytes(int fd, long long byte, int bytes, void *buff)
{
off_t off = byte;
int res, count;
TRACE("read_bytes: reading from position 0x%llx, bytes %d\n", byte,
bytes);
if(lseek(fd, off + squashfs_start_offset, SEEK_SET) == -1) {
ERROR("Lseek failed because %s\n", strerror(errno));
return FALSE;
}
for(count = 0; count < bytes; count += res) {
res = read(fd, buff + count, bytes - count);
if(res < 1) {
if(res == 0) {
ERROR("Read on filesystem failed because "
"EOF\n");
return FALSE;
} else if(errno != EINTR) {
ERROR("Read on filesystem failed because %s\n",
strerror(errno));
return FALSE;
} else
res = 0;
}
}
return TRUE;
}
| 2,290 |
87,086 | 0 | CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name)
{
cJSON *array = cJSON_CreateArray();
if (add_item_to_object(object, name, array, &global_hooks, false))
{
return array;
}
cJSON_Delete(array);
return NULL;
}
| 2,291 |
153,633 | 0 | void GLES2Implementation::DrawElements(GLenum mode,
GLsizei count,
GLenum type,
const void* indices) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDrawElements("
<< GLES2Util::GetStringDrawMode(mode) << ", " << count
<< ", " << GLES2Util::GetStringIndexType(type) << ", "
<< static_cast<const void*>(indices) << ")");
DrawElementsImpl(mode, count, type, indices, "glDrawElements");
}
| 2,292 |
16,122 | 0 | GahpServer::RemoveGahpClient()
{
m_reference_count--;
if ( m_reference_count <= 0 ) {
m_deleteMeTid = daemonCore->Register_Timer( 30,
(TimerHandlercpp)&GahpServer::DeleteMe,
"GahpServer::DeleteMe", (Service*)this );
}
}
| 2,293 |
69,817 | 0 | nodelist_add_node_and_family(smartlist_t *sl, const node_t *node)
{
const smartlist_t *all_nodes = nodelist_get_list();
const smartlist_t *declared_family;
const or_options_t *options = get_options();
tor_assert(node);
declared_family = node_get_declared_family(node);
/* Let's make sure that we have the node itself, if it's a real node. */
{
const node_t *real_node = node_get_by_id(node->identity);
if (real_node)
smartlist_add(sl, (node_t*)real_node);
}
/* First, add any nodes with similar network addresses. */
if (options->EnforceDistinctSubnets) {
tor_addr_t node_addr;
node_get_addr(node, &node_addr);
SMARTLIST_FOREACH_BEGIN(all_nodes, const node_t *, node2) {
tor_addr_t a;
node_get_addr(node2, &a);
if (addrs_in_same_network_family(&a, &node_addr))
smartlist_add(sl, (void*)node2);
} SMARTLIST_FOREACH_END(node2);
}
/* Now, add all nodes in the declared_family of this node, if they
* also declare this node to be in their family. */
if (declared_family) {
/* Add every r such that router declares familyness with node, and node
* declares familyhood with router. */
SMARTLIST_FOREACH_BEGIN(declared_family, const char *, name) {
const node_t *node2;
const smartlist_t *family2;
if (!(node2 = node_get_by_nickname(name, 0)))
continue;
if (!(family2 = node_get_declared_family(node2)))
continue;
SMARTLIST_FOREACH_BEGIN(family2, const char *, name2) {
if (node_nickname_matches(node, name2)) {
smartlist_add(sl, (void*)node2);
break;
}
} SMARTLIST_FOREACH_END(name2);
} SMARTLIST_FOREACH_END(name);
}
/* If the user declared any families locally, honor those too. */
if (options->NodeFamilySets) {
SMARTLIST_FOREACH(options->NodeFamilySets, const routerset_t *, rs, {
if (routerset_contains_node(rs, node)) {
routerset_get_all_nodes(sl, rs, NULL, 0);
}
});
}
}
| 2,294 |
34,999 | 0 | static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_addrs,
void __user *to)
{
struct list_head *pos, *next;
struct sctp_sockaddr_entry *addr;
union sctp_addr temp;
int cnt = 0;
int addrlen;
list_for_each_safe(pos, next, &sctp_local_addr_list) {
addr = list_entry(pos, struct sctp_sockaddr_entry, list);
if ((PF_INET == sk->sk_family) &&
(AF_INET6 == addr->a.sa.sa_family))
continue;
memcpy(&temp, &addr->a, sizeof(temp));
sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
&temp);
addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
if (copy_to_user(to, &temp, addrlen))
return -EFAULT;
to += addrlen;
cnt ++;
if (cnt >= max_addrs) break;
}
return cnt;
}
| 2,295 |
150,759 | 0 | void BluetoothDeviceChooserController::PopulateConnectedDevices() {
for (const device::BluetoothDevice* device : adapter_->GetDevices()) {
if (device->IsGattConnected()) {
AddFilteredDevice(*device);
}
}
}
| 2,296 |
115,913 | 0 | void ewk_frame_force_layout(Evas_Object* ewkFrame)
{
DBG("ewkFrame=%p", ewkFrame);
EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData);
EINA_SAFETY_ON_NULL_RETURN(smartData->frame);
WebCore::FrameView* view = smartData->frame->view();
if (view)
view->forceLayout(true);
}
| 2,297 |
74,552 | 0 | static ssize_t regulator_suspend_standby_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct regulator_dev *rdev = dev_get_drvdata(dev);
return regulator_print_opmode(buf,
rdev->constraints->state_standby.mode);
}
| 2,298 |
16,338 | 0 | BaseShadow::logEvictEvent( int exitReason )
{
struct rusage run_remote_rusage;
memset( &run_remote_rusage, 0, sizeof(struct rusage) );
run_remote_rusage = getRUsage();
switch( exitReason ) {
case JOB_CKPTED:
case JOB_NOT_CKPTED:
case JOB_KILLED:
break;
default:
dprintf( D_ALWAYS,
"logEvictEvent with unknown reason (%d), aborting\n",
exitReason );
return;
}
JobEvictedEvent event;
event.checkpointed = (exitReason == JOB_CKPTED);
event.run_remote_rusage = run_remote_rusage;
/*
we want to log the events from the perspective of the user
job, so if the shadow *sent* the bytes, then that means the
user job *received* the bytes
*/
event.recvd_bytes = bytesSent();
event.sent_bytes = bytesReceived();
if (!uLog.writeEvent (&event,jobAd)) {
dprintf (D_ALWAYS, "Unable to log ULOG_JOB_EVICTED event\n");
}
}
| 2,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.