这篇教程C++ xalloc函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ xalloc函数的具体用法?C++ xalloc怎么用?C++ xalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xalloc函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: xf86RandR12CrtcSetstatic Boolxf86RandR12CrtcSet (ScreenPtr pScreen, RRCrtcPtr randr_crtc, RRModePtr randr_mode, int x, int y, Rotation rotation, int num_randr_outputs, RROutputPtr *randr_outputs){ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); xf86CrtcPtr crtc = randr_crtc->devPrivate; RRTransformPtr transform; Bool changed = FALSE; int o, ro; xf86CrtcPtr *save_crtcs; Bool save_enabled = crtc->enabled; if (!crtc->scrn->vtSema) return FALSE; save_crtcs = xalloc(config->num_output * sizeof (xf86CrtcPtr)); if ((randr_mode != NULL) != crtc->enabled) changed = TRUE; else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode)) changed = TRUE; if (rotation != crtc->rotation) changed = TRUE; transform = RRCrtcGetTransform (randr_crtc); if ((transform != NULL) != crtc->transformPresent) changed = TRUE; else if (transform && memcmp (&transform->transform, &crtc->transform.transform, sizeof (transform->transform)) != 0) changed = TRUE; if (x != crtc->x || y != crtc->y) changed = TRUE; for (o = 0; o < config->num_output; o++) { xf86OutputPtr output = config->output[o]; xf86CrtcPtr new_crtc; save_crtcs[o] = output->crtc; if (output->crtc == crtc) new_crtc = NULL; else new_crtc = output->crtc; for (ro = 0; ro < num_randr_outputs; ro++) if (output->randr_output == randr_outputs[ro]) { new_crtc = crtc; break; } if (new_crtc != output->crtc) { changed = TRUE; output->crtc = new_crtc; } } for (ro = 0; ro < num_randr_outputs; ro++) if (randr_outputs[ro]->pendingProperties) changed = TRUE; /* XXX need device-independent mode setting code through an API */ if (changed) { crtc->enabled = randr_mode != NULL; if (randr_mode) { DisplayModeRec mode; RRTransformPtr transform = RRCrtcGetTransform (randr_crtc); xf86RandRModeConvert (pScrn, randr_mode, &mode); if (!xf86CrtcSetModeTransform (crtc, &mode, rotation, transform, x, y)) { crtc->enabled = save_enabled; for (o = 0; o < config->num_output; o++) { xf86OutputPtr output = config->output[o]; output->crtc = save_crtcs[o]; } xfree(save_crtcs); return FALSE; } xf86RandR13VerifyPanningArea (crtc, pScreen->width, pScreen->height); xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY); /* * Save the last successful setting for EnterVT */ crtc->desiredMode = mode; crtc->desiredRotation = rotation; if (transform) { crtc->desiredTransform = *transform; crtc->desiredTransformPresent = TRUE;//.........这里部分代码省略.........
开发者ID:mozyg,项目名称:xorg,代码行数:101,
示例2: test_eddsa_sign#include "testutils.h"#include "eddsa.h"#include "eddsa-internal.h"static voidtest_eddsa_sign (const struct ecc_curve *ecc, const struct nettle_hash *H, const struct tstring *public, const struct tstring *private, const struct tstring *msg, const struct tstring *ref){ mp_limb_t *scratch = xalloc_limbs (_eddsa_sign_itch (ecc)); size_t nbytes = 1 + ecc->p.bit_size / 8; uint8_t *signature = xalloc (2*nbytes); void *ctx = xalloc (H->context_size); uint8_t *public_out = xalloc (nbytes); uint8_t *digest = xalloc (2*nbytes); const uint8_t *k1 = digest + nbytes; mp_limb_t *k2 = xalloc_limbs (ecc->p.size); ASSERT (public->length == nbytes); ASSERT (private->length == nbytes); ASSERT (ref->length == 2*nbytes); _eddsa_expand_key (ecc, H, ctx, private->data, digest, k2); _eddsa_public_key (ecc, k2, public_out, scratch); if (!MEMEQ (nbytes, public_out, public->data))
开发者ID:gnutls,项目名称:nettle,代码行数:31,
示例3: build_note_list_from_event_list/* This function builds a note list from an event list. This note list is sorted by increasing starting time. And notes are broken up so that each pair of notes either cover the identical time interval or they cover disjoint intervals. The following fields of each note are filled in: start, duration, pitch, npc, base_tpc, next */Note * build_note_list_from_event_list(Event * e) { int event_time, previous_event_time; int on_event, i, xet, event_n; Pitch pitch; Note * note_list, * new_note; char pitch_in_use[MAX_PITCH]; DirectNote * directnote[MAX_PITCH]; /* for each pitch in use we need the direct note that created it */ char already_emitted[MAX_PITCH]; /* to compute the is_first_note fields */ int pitch_count[MAX_PITCH]; /* the number of times the pitch is turned on */ Event *el; Event ** etable; int N_events; for (N_events=0, el = e; el != NULL; el = el->next) N_events++; etable = (Event **) xalloc (N_events * sizeof (Event *)); for (i=0, el = e; el != NULL; el = el->next, i++) etable[i] = el; qsort(etable, N_events, sizeof (Event *), (int (*)(const void *, const void *))comp_event2); for(i=0; i<MAX_PITCH; i++) { pitch_in_use[i] = 0; already_emitted[i] = 0; directnote[i] = NULL; pitch_count[i] = 0; } event_time = 0; note_list = NULL; /* for (i=0; i<N_events; i++) { el = etable[i]; printf("event: pitch = %d note_on = %d time = %d /n", el->pitch, el->note_on, el->time); } */ for (event_n=0; event_n<N_events; event_n++) { el = etable[event_n]; xet = el->time; pitch = el->pitch; on_event = el->note_on; /* we ignore an event that doesn't change which pitches are currently on, that is, a situation where two notes are overlapping */ if (on_event) { pitch_count[pitch]++; if (pitch_count[pitch] > 1) continue; } else { pitch_count[pitch]--; if (pitch_count[pitch] > 0) continue; } previous_event_time = event_time; event_time = xet; /* now, for each pitch that's turned on, we generate a note */ /* the onset time is previous_event_time, the duration is */ /* the diff between that and event_time */ if (previous_event_time > event_time) { fprintf(stderr, "%s: Events are not sorted by time./n", this_program); my_exit(1); } if (previous_event_time != event_time) { /* Don't create any notes unless some time has elapsed */ for(i=0; i<MAX_PITCH; i++) { if (pitch_in_use[i]) { new_note = (Note*) xalloc(sizeof(Note)); new_note->pitch = i; new_note->start = previous_event_time; new_note->duration = event_time - previous_event_time; new_note->npc = new_note->base_tpc = new_note->tpc = 0; new_note->orn_dis_penalty = 0.0; new_note->next = note_list; new_note->is_first_note = (!already_emitted[i]); new_note->directnote = directnote[i]; already_emitted[i] = 1; note_list = new_note; } } } pitch_in_use[pitch] = on_event; directnote[pitch] = el->directnote; /* NULL if not an on_event */ already_emitted[pitch] = 0; } for(i=0; i<MAX_PITCH; i++) { if (pitch_in_use[i]) { fprintf(stderr, "%s: Pitch %d was still in use at the end./n", this_program, i); my_exit(1);//.........这里部分代码省略.........
开发者ID:kroger,项目名称:rameau,代码行数:101,
示例4: PclPolyLinevoidPclPolyLine( DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints, xPoint *pPoints){ char t[80]; FILE *outFile; int xoffset = 0, yoffset = 0; int nbox; BoxPtr pbox; xRectangle *drawRects, *r; RegionPtr drawRegion, region; short fudge; int i; XpContextPtr pCon; PclContextPrivPtr pConPriv; if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE ) return; pCon = PclGetContextFromWindow( (WindowPtr) pDrawable ); pConPriv = (PclContextPrivPtr) pCon->devPrivates[PclContextPrivateIndex].ptr; /* * Allocate the storage required to deal with the clipping * regions. */ region = REGION_CREATE( pGC->pScreen, NULL, 0 ); drawRects = (xRectangle *) xalloc( ( nPoints - 1 ) * sizeof( xRectangle ) ); /* * Calculate the "fudge factor" based on the line width. * Multiplying by three seems to be a good first guess. * XXX I need to think of a way to test this. */ fudge = 3 * pGC->lineWidth + 1; /* * Generate the PCL code to draw the polyline, by defining it as a * macro which uses the HP-GL/2 line drawing function. */ MACRO_START( outFile, pConPriv ); SAVE_PCL( outFile, pConPriv, "/033%0B" ); sprintf( t, "PU%d,%dPD/n", pPoints[0].x + pDrawable->x, pPoints[0].y + pDrawable->y ); SAVE_PCL( outFile, pConPriv, t ); /* Move to the start of the polyline */ switch( mode ) { case CoordModeOrigin: xoffset = pDrawable->x; yoffset = pDrawable->y; SAVE_PCL( outFile, pConPriv, "PA" ); break; case CoordModePrevious: xoffset = yoffset = 0; SAVE_PCL( outFile, pConPriv, "PR" ); break; } /* * Build the "drawing region" as we build the PCL to draw the * line. */ for(i = 1, r = drawRects; i < nPoints; i++, r++ ) { if( i != 1 ) SAVE_PCL( outFile, pConPriv, "," ); sprintf( t, "%d,%d", pPoints[i].x + xoffset, pPoints[i].y + yoffset ); SAVE_PCL( outFile, pConPriv, t ); r->x = MIN( pPoints[i-1].x, pPoints[i].x ) + xoffset - fudge; r->y = MIN( pPoints[i-1].y, pPoints[i].y ) + yoffset - fudge; r->width = abs( pPoints[i-1].x - pPoints[i].x ) + 2 * fudge; r->height = abs( pPoints[i-1].y - pPoints[i].y ) + 2 * fudge; } SAVE_PCL( outFile, pConPriv, ";/033%0A" ); /* End the macro */ MACRO_END( outFile ); /* * Convert the collection of rectangles into a proper region, then * intersect it with the clip region. */ drawRegion = RECTS_TO_REGION( pGC->pScreen, nPoints - 1, drawRects, CT_UNSORTED ); if( mode == CoordModePrevious ) REGION_TRANSLATE( pGC->pScreen, drawRegion, pPoints[0].x, pPoints[0].y ); REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip ); /* * For each rectangle in the clip region, set the HP-GL/2 "input//.........这里部分代码省略.........
开发者ID:aosm,项目名称:X11,代码行数:101,
示例5: test_cipher_streamvoidtest_cipher_stream(const struct nettle_cipher *cipher, const struct tstring *key, const struct tstring *cleartext, const struct tstring *ciphertext){ unsigned block; void *ctx = xalloc(cipher->context_size); uint8_t *data; unsigned length; ASSERT (cleartext->length == ciphertext->length); length = cleartext->length; data = xalloc(length + 1); for (block = 1; block <= length; block++) { unsigned i; memset(data, 0x17, length + 1); cipher->set_encrypt_key(ctx, key->length, key->data); for (i = 0; i + block < length; i += block) { cipher->encrypt(ctx, block, data + i, cleartext->data + i); ASSERT (data[i + block] == 0x17); } cipher->encrypt(ctx, length - i, data + i, cleartext->data + i); ASSERT (data[length] == 0x17); if (!MEMEQ(length, data, ciphertext->data)) { fprintf(stderr, "Encrypt failed, block size %d/nInput:", block); tstring_print_hex(cleartext); fprintf(stderr, "/nOutput: "); print_hex(length, data); fprintf(stderr, "/nExpected:"); tstring_print_hex(ciphertext); fprintf(stderr, "/n"); FAIL(); } } cipher->set_decrypt_key(ctx, key->length, key->data); cipher->decrypt(ctx, length, data, data); ASSERT (data[length] == 0x17); if (!MEMEQ(length, data, cleartext->data)) { fprintf(stderr, "Decrypt failed/nInput:"); tstring_print_hex(ciphertext); fprintf(stderr, "/nOutput: "); print_hex(length, data); fprintf(stderr, "/nExpected:"); tstring_print_hex(cleartext); fprintf(stderr, "/n"); FAIL(); } free(ctx); free(data);}
开发者ID:AllardJ,项目名称:Tomato,代码行数:66,
示例6: IntervalListCreateSetstatic RecordSetPtrIntervalListCreateSet(RecordSetInterval *pIntervals, int nIntervals, void *pMem, int memsize){ IntervalListSetPtr prls; int i, j, k; RecordSetInterval *stackIntervals = NULL; CARD16 first; if (nIntervals > 0) { stackIntervals = (RecordSetInterval *)xalloc( sizeof(RecordSetInterval) * nIntervals); if (!stackIntervals) return NULL; /* sort intervals, store in stackIntervals (insertion sort) */ for (i = 0; i < nIntervals; i++) { first = pIntervals[i].first; for (j = 0; j < i; j++) { if (first < stackIntervals[j].first) break; } for (k = i; k > j; k--) { stackIntervals[k] = stackIntervals[k-1]; } stackIntervals[j] = pIntervals[i]; } /* merge abutting/overlapping intervals */ for (i = 0; i < nIntervals - 1; ) { if ( (stackIntervals[i].last + (unsigned int)1) < stackIntervals[i + 1].first) { i++; /* disjoint intervals */ } else { stackIntervals[i].last = max(stackIntervals[i].last, stackIntervals[i + 1].last); nIntervals--; for (j = i + 1; j < nIntervals; j++) stackIntervals[j] = stackIntervals[j + 1]; } } } /* allocate and fill in set structure */ if (pMem) { prls = (IntervalListSetPtr)pMem; prls->baseSet.ops = &IntervalListNoFreeOperations; } else { prls = (IntervalListSetPtr) xalloc(sizeof(IntervalListSet) + nIntervals * sizeof(RecordSetInterval)); if (!prls) goto bailout; prls->baseSet.ops = &IntervalListSetOperations; } memcpy(&prls[1], stackIntervals, nIntervals * sizeof(RecordSetInterval)); prls->nIntervals = nIntervals;bailout: if (stackIntervals) xfree(stackIntervals); return (RecordSetPtr)prls;}
开发者ID:L3oV1nc3,项目名称:VMGL,代码行数:72,
示例7: XAAValidateGCstatic voidXAAValidateGC( GCPtr pGC, unsigned long changes, DrawablePtr pDraw ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); XAA_GC_FUNC_PROLOGUE(pGC); (*pGC->funcs->ValidateGC)(pGC, changes, pDraw); if((changes & GCPlaneMask) && ((pGC->planemask & infoRec->FullPlanemasks[pGC->depth - 1]) == infoRec->FullPlanemasks[pGC->depth - 1])) { pGC->planemask = ~0; } if(pGC->depth != 32) { /* 0xffffffff is reserved for transparency */ if(pGC->bgPixel == 0xffffffff) pGC->bgPixel = 0x7fffffff; if(pGC->fgPixel == 0xffffffff) pGC->fgPixel = 0x7fffffff; } if((pDraw->type == DRAWABLE_PIXMAP) && !IS_OFFSCREEN_PIXMAP(pDraw)){ pGCPriv->flags = OPS_ARE_PIXMAP; pGCPriv->changes |= changes; /* make sure we're not using videomemory pixmaps to render onto system memory drawables */ if((pGC->fillStyle == FillTiled) && IS_OFFSCREEN_PIXMAP(pGC->tile.pixmap) && !OFFSCREEN_PIXMAP_LOCKED(pGC->tile.pixmap)) { XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); FBAreaPtr area = pPriv->offscreenArea; XAARemoveAreaCallback(area); /* clobbers pPriv->offscreenArea */ xf86FreeOffscreenArea(area); } } else if(!infoRec->pScrn->vtSema && (pDraw->type == DRAWABLE_WINDOW)) { pGCPriv->flags = 0; pGCPriv->changes |= changes; } else { if(!(pGCPriv->flags & OPS_ARE_ACCEL)) { changes |= pGCPriv->changes; pGCPriv->changes = 0; } pGCPriv->flags = OPS_ARE_ACCEL;#if 1 /* Ugh. If we can't use the blitter on offscreen pixmaps used as tiles, then we need to move them out as cfb can't handle tiles with non-zero origins */ if((pGC->fillStyle == FillTiled) && IS_OFFSCREEN_PIXMAP(pGC->tile.pixmap) && (DO_PIXMAP_COPY != (*infoRec->TiledFillChooser)(pGC))) { XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); FBAreaPtr area = pPriv->offscreenArea; XAARemoveAreaCallback(area); /* clobbers pPriv->offscreenArea */ xf86FreeOffscreenArea(area); }#endif } XAA_GC_FUNC_EPILOGUE(pGC); if(!(pGCPriv->flags & OPS_ARE_ACCEL)) return; if((changes & GCTile) && !pGC->tileIsPixel && pGC->tile.pixmap){ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap); if(pixPriv->flags & DIRTY) { pixPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK); pGC->tile.pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; } } if((changes & GCStipple) && pGC->stipple){ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple); if(pixPriv->flags & DIRTY) { pixPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK); pGC->stipple->drawable.serialNumber = NEXT_SERIAL_NUMBER; } } /* If our Ops are still the default ones we need to allocate new ones */ if(pGC->ops == &XAAFallbackOps) { if(!(pGCPriv->XAAOps = xalloc(sizeof(GCOps)))) { pGCPriv->XAAOps = &XAAFallbackOps; return; }//.........这里部分代码省略.........
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:101,
示例8: xf86scanpci//.........这里部分代码省略......... pcr._device_vendor = inl(0xCFC); if (pcr._vendor == 0xFFFF) /* nothing there */ continue;#ifdef DEBUGPCI printf("/npci bus 0x%x cardnum 0x%02x, vendor 0x%04x device 0x%04x/n", pcr._pcibuses[pcr._pcibusidx], pcr._cardnum, pcr._vendor, pcr._device);#endif outl(0xCF8, config_cmd | 0x04); pcr._status_command = inl(0xCFC); outl(0xCF8, config_cmd | 0x08); pcr._class_revision = inl(0xCFC); outl(0xCF8, config_cmd | 0x0C); pcr._bist_header_latency_cache = inl(0xCFC); outl(0xCF8, config_cmd | 0x10); pcr._base0 = inl(0xCFC); outl(0xCF8, config_cmd | 0x14); pcr._base1 = inl(0xCFC); outl(0xCF8, config_cmd | 0x18); pcr._base2 = inl(0xCFC); outl(0xCF8, config_cmd | 0x1C); pcr._base3 = inl(0xCFC); outl(0xCF8, config_cmd | 0x20); pcr._base4 = inl(0xCFC); outl(0xCF8, config_cmd | 0x24); pcr._base5 = inl(0xCFC); outl(0xCF8, config_cmd | 0x30); pcr._baserom = inl(0xCFC); outl(0xCF8, config_cmd | 0x3C); pcr._max_min_ipin_iline = inl(0xCFC); /* check for pci-pci bridges (currently we only know Digital) */ if ((pcr._vendor == 0x1011) && (pcr._device == 0x0001)) if (pcr._secondary_bus_number > 0) pcr._pcibuses[pcr._pcinumbus++] = pcr._secondary_bus_number; if (idx >= MAX_PCI_DEVICES) continue; if ((pci_devp[idx] = (struct pci_config_reg *)xalloc(sizeof( struct pci_config_reg))) == (struct pci_config_reg *)NULL) { outl(0xCF8, 0x00); xf86DisableIOPorts(0); xf86ClearIOPortList(0); return; } memcpy(pci_devp[idx++], &pcr, sizeof(struct pci_config_reg)); } } while (++pcr._pcibusidx < pcr._pcinumbus);#ifndef DEBUGPCI if (pcr._configtype == 1) { outl(0xCF8, 0x00); return; }#endif /* Now try pci config 2 probe (deprecated) */ outb(0xCF8, 0xF1); outb(0xCFA, 0x00); /* bus 0 for now */#ifdef DEBUGPCI printf("/nPCI probing configuration type 2/n");#endif pcr._pcibuses[0] = 0; pcr._pcinumbus = 1; pcr._pcibusidx = 0; do { for (pcr._ioaddr = 0xC000; pcr._ioaddr < 0xD000; pcr._ioaddr += 0x0100){
开发者ID:berkus,项目名称:nemesis,代码行数:67,
示例9: verify_auth_infoint verify_auth_info (char * name, char * user_to_be){ int allowed = 0; char ** user_list = NULL; size_t l_line = 0; int nb_users = 0; char * line, * ptr; char * line_name, * line_shell; char * group_name = NULL, * group = NULL, **p; struct group *gr_group; /* * let's search if user allowed or not */#ifdef HAVE_WORKING_SYSCONF l_line = (size_t) sysconf (_SC_LINE_MAX); /* returns long usually */#else l_line = MAX_STRING;#endif /* HAVE_WORKING_SYSCONF */ line = (char *) xalloc (l_line); while (!feof (fp)) { int lastc; if (fgets (line, l_line, fp) == NULL) break; /* * remove trailing '/n' if present */ lastc = strlen (line) - 1; if (line [lastc] == '/n') line [lastc] = '/0'; /* * empty line or comment or null login -- not allowed but ignored */ if (!line || (*line) == '#' || (*line) == '/0') continue; MESSAGE_1 ("Line read = |%s|/n", line); line_name = line; /* * Look for a @ or % as first character (for groups) */ if (*line == '@' || *line == '%') { group = strdup(line); group_name = strtok(group, ":"); group_name++; /* skip '@' */ /* * Look into /etc/groups (or its equivalent with get) */ gr_group = (struct group *) getgrnam(group_name); if (gr_group == NULL) { die(1, "No such group %s", group_name); allowed = 0; goto end; } for ( p = &gr_group->gr_mem[0]; *p ; p++ ) { MESSAGE_3 ("matching %s to %s in %s/n", name, *p, group_name); if (strcmp(name, *p) == 0) { MESSAGE_2 ("User %s Allowed through group %s/n", name, group_name); _group = strdup (group_name); strcpy (_group, group_name); allowed = 2; break; } } } /* * Look for first ':' */ ptr = strchr (line, ':'); if (ptr == NULL) { /* * No shell and no user list */ custom_shell = 0; /* * Bypass if already allowed through group */ if (group_name != NULL && allowed == 1) goto escape; if (strcmp (line_name, name)) /* not us */ continue; goto escape; } /* * I got a ':', put a '/0' instead. */ *ptr++ = '/0'; /* * Do we have anything behind ? */ if (*ptr == '/0')//.........这里部分代码省略.........
开发者ID:keltia,项目名称:calife,代码行数:101,
示例10: xf86CrtcRotate_X_EXPORT Boolxf86CrtcRotate (xf86CrtcPtr crtc){ ScrnInfoPtr pScrn = crtc->scrn; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */ ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; PictTransform crtc_to_fb; struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc; xFixed *new_params = NULL; int new_nparams = 0; PictFilterPtr new_filter = NULL; int new_width = 0; int new_height = 0; RRTransformPtr transform = NULL; Bool damage = FALSE; if (crtc->transformPresent) transform = &crtc->transform; if (!RRTransformCompute (crtc->x, crtc->y, crtc->mode.HDisplay, crtc->mode.VDisplay, crtc->rotation, transform, &crtc_to_fb, &f_crtc_to_fb, &f_fb_to_crtc) && xf86CrtcFitsScreen (crtc, &f_crtc_to_fb)) { /* * If the untranslated transformation is the identity, * disable the shadow buffer */ xf86RotateDestroy (crtc); crtc->transform_in_use = FALSE; if (new_params) xfree (new_params); new_params = NULL; new_nparams = 0; new_filter = NULL; new_width = 0; new_height = 0; } else { /* * these are the size of the shadow pixmap, which * matches the mode, not the pre-rotated copy in the * frame buffer */ int width = crtc->mode.HDisplay; int height = crtc->mode.VDisplay; void *shadowData = crtc->rotatedData; PixmapPtr shadow = crtc->rotatedPixmap; int old_width = shadow ? shadow->drawable.width : 0; int old_height = shadow ? shadow->drawable.height : 0; /* Allocate memory for rotation */ if (old_width != width || old_height != height) { if (shadow || shadowData) { crtc->funcs->shadow_destroy (crtc, shadow, shadowData); crtc->rotatedPixmap = NULL; crtc->rotatedData = NULL; } shadowData = crtc->funcs->shadow_allocate (crtc, width, height); if (!shadowData) goto bail1; crtc->rotatedData = shadowData; /* shadow will be damaged in xf86RotatePrepare */ } else { /* mark shadowed area as damaged so it will be repainted */ damage = TRUE; } if (!xf86_config->rotation_damage) { /* Create damage structure */ xf86_config->rotation_damage = DamageCreate (NULL, NULL, DamageReportNone, TRUE, pScreen, pScreen); if (!xf86_config->rotation_damage) goto bail2; /* Wrap block handler */ if (!xf86_config->BlockHandler) { xf86_config->BlockHandler = pScreen->BlockHandler; pScreen->BlockHandler = xf86RotateBlockHandler; } }#ifdef RANDR_12_INTERFACE if (transform) { if (transform->nparams) { new_params = xalloc (transform->nparams * sizeof (xFixed)); if (new_params) {//.........这里部分代码省略.........
开发者ID:aosm,项目名称:X11server,代码行数:101,
示例11: restricted_expressionExp * restricted_expression(Dictionary dict, int and_ok, int or_ok) { Exp * nl=NULL, * nr, * n; E_list *ell, *elr; if (is_equal(dict, L'(')) { if (!advance(dict)) { return NULL; } nl = expression(dict); if (nl == NULL) { return NULL; } if (!is_equal(dict, L')')) { dict_error(dict, L"Expecting a /")/"."); return NULL; } if (!advance(dict)) { return NULL; } } else if (is_equal(dict, L'{')) { if (!advance(dict)) { return NULL; } nl = expression(dict); if (nl == NULL) { return NULL; } if (!is_equal(dict, L'}')) { dict_error(dict, L"Expecting a /"}/"."); return NULL; } if (!advance(dict)) { return NULL; } nl = make_optional_node(dict, nl); } else if (is_equal(dict, L'[')) { if (!advance(dict)) { return NULL; } nl = expression(dict); if (nl == NULL) { return NULL; } if (!is_equal(dict, L']')) { dict_error(dict, L"Expecting a /"]/"."); return NULL; } if (!advance(dict)) { return NULL; } nl->cost += 1; } else if (!dict->is_special) { nl = connector(dict); if (nl == NULL) { return NULL; } } else if (is_equal(dict, L')') || is_equal(dict, L']')) { /* allows "()" or "[]" */ nl = make_zeroary_node(dict); } else { dict_error(dict, L"Connector, /"(/", /"[/", or /"{/" expected."); return NULL; } if (is_equal(dict, L'&') || (wcscmp(dict->token, L"and")==0)) { if (!and_ok) { warning(dict, L"/"and/" and /"or/" at the same level in an expression"); } if (!advance(dict)) { return NULL; } nr = restricted_expression(dict, TRUE,FALSE); if (nr == NULL) { return NULL; } n = Exp_create(dict); n->u.l = ell = (E_list *) xalloc(sizeof(E_list)); ell->next = elr = (E_list *) xalloc(sizeof(E_list)); elr->next = NULL; ell->e = nl; elr->e = nr; n->type = AND_type; n->cost = 0; } else if (is_equal(dict, L'|') || (wcscmp(dict->token, L"or")==0)) { if (!or_ok) { warning(dict, L"/"and/" and /"or/" at the same level in an expression"); } if (!advance(dict)) { return NULL; } nr = restricted_expression(dict, FALSE,TRUE); if (nr == NULL) { return NULL; } n = Exp_create(dict); n->u.l = ell = (E_list *) xalloc(sizeof(E_list)); ell->next = elr = (E_list *) xalloc(sizeof(E_list)); elr->next = NULL; ell->e = nl;//.........这里部分代码省略.........
开发者ID:IncorexLLC,项目名称:Elchi,代码行数:101,
示例12: ProcXDGAQueryModesstatic intProcXDGAQueryModes(ClientPtr client){ int i, num, size; REQUEST(xXDGAQueryModesReq); xXDGAQueryModesReply rep; xXDGAModeInfo info; XDGAModePtr mode; if (stuff->screen > screenInfo.numScreens) return BadValue; REQUEST_SIZE_MATCH(xXDGAQueryModesReq); rep.type = X_Reply; rep.length = 0; rep.number = 0; rep.sequenceNumber = client->sequence; if (!DGAAvailable(stuff->screen)) { rep.number = 0; rep.length = 0; WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); return (client->noClientException); } if(!(num = DGAGetModes(stuff->screen))) { WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); return (client->noClientException); } if(!(mode = (XDGAModePtr)xalloc(num * sizeof(XDGAModeRec)))) return BadAlloc; for(i = 0; i < num; i++) DGAGetModeInfo(stuff->screen, mode + i, i + 1); size = num * sz_xXDGAModeInfo; for(i = 0; i < num; i++) size += (strlen(mode[i].name) + 4) & ~3L; /* plus NULL */ rep.number = num; rep.length = size >> 2; WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep); for(i = 0; i < num; i++) { size = strlen(mode[i].name) + 1; info.byte_order = mode[i].byteOrder; info.depth = mode[i].depth; info.num = mode[i].num; info.bpp = mode[i].bitsPerPixel; info.name_size = (size + 3) & ~3L; info.vsync_num = mode[i].VSync_num; info.vsync_den = mode[i].VSync_den; info.flags = mode[i].flags; info.image_width = mode[i].imageWidth; info.image_height = mode[i].imageHeight; info.pixmap_width = mode[i].pixmapWidth; info.pixmap_height = mode[i].pixmapHeight; info.bytes_per_scanline = mode[i].bytesPerScanline; info.red_mask = mode[i].red_mask; info.green_mask = mode[i].green_mask; info.blue_mask = mode[i].blue_mask; info.visual_class = mode[i].visualClass; info.viewport_width = mode[i].viewportWidth; info.viewport_height = mode[i].viewportHeight; info.viewport_xstep = mode[i].xViewportStep; info.viewport_ystep = mode[i].yViewportStep; info.viewport_xmax = mode[i].maxViewportX; info.viewport_ymax = mode[i].maxViewportY; info.viewport_flags = mode[i].viewportFlags; info.reserved1 = mode[i].reserved1; info.reserved2 = mode[i].reserved2; WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info)); WriteToClient(client, size, mode[i].name); } xfree(mode); return (client->noClientException);}
开发者ID:dikerex,项目名称:theqvd,代码行数:83,
示例13: xf86RandR12SetInfo12/* * Mirror the current mode configuration to RandR */static Boolxf86RandR12SetInfo12 (ScreenPtr pScreen){ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); RROutputPtr *clones; RRCrtcPtr *crtcs; int ncrtc; int o, c, l; RRCrtcPtr randr_crtc; int nclone; clones = xalloc(config->num_output * sizeof (RROutputPtr)); crtcs = xalloc (config->num_crtc * sizeof (RRCrtcPtr)); for (o = 0; o < config->num_output; o++) { xf86OutputPtr output = config->output[o]; ncrtc = 0; for (c = 0; c < config->num_crtc; c++) if (output->possible_crtcs & (1 << c)) crtcs[ncrtc++] = config->crtc[c]->randr_crtc; if (output->crtc) randr_crtc = output->crtc->randr_crtc; else randr_crtc = NULL; if (!RROutputSetCrtcs (output->randr_output, crtcs, ncrtc)) { xfree (crtcs); xfree (clones); return FALSE; } RROutputSetPhysicalSize(output->randr_output, output->mm_width, output->mm_height); xf86RROutputSetModes (output->randr_output, output->probed_modes); switch (output->status) { case XF86OutputStatusConnected: RROutputSetConnection (output->randr_output, RR_Connected); break; case XF86OutputStatusDisconnected: RROutputSetConnection (output->randr_output, RR_Disconnected); break; case XF86OutputStatusUnknown: RROutputSetConnection (output->randr_output, RR_UnknownConnection); break; } RROutputSetSubpixelOrder (output->randr_output, output->subpixel_order); /* * Valid clones */ nclone = 0; for (l = 0; l < config->num_output; l++) { xf86OutputPtr clone = config->output[l]; if (l != o && (output->possible_clones & (1 << l))) clones[nclone++] = clone->randr_output; } if (!RROutputSetClones (output->randr_output, clones, nclone)) { xfree (crtcs); xfree (clones); return FALSE; } } xfree (crtcs); xfree (clones); return TRUE;}
开发者ID:mozyg,项目名称:xorg,代码行数:79,
示例14: ProcXResQueryClientResourcesstatic intProcXResQueryClientResources (ClientPtr client){ REQUEST(xXResQueryClientResourcesReq); xXResQueryClientResourcesReply rep; int i, clientID, num_types; int *counts; REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq); clientID = CLIENT_ID(stuff->xid); if((clientID >= currentMaxClients) || !clients[clientID]) { client->errorValue = stuff->xid; return BadValue; } counts = xalloc((lastResourceType + 1) * sizeof(int)); memset(counts, 0, (lastResourceType + 1) * sizeof(int)); FindAllClientResources(clients[clientID], ResFindAllRes, counts); num_types = 0; for(i = 0; i <= lastResourceType; i++) { if(counts[i]) num_types++; } rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.num_types = num_types; rep.length = rep.num_types * sz_xXResType >> 2; if (client->swapped) { int n; swaps (&rep.sequenceNumber, n); swapl (&rep.length, n); swapl (&rep.num_types, n); } WriteToClient (client,sizeof(xXResQueryClientResourcesReply),(char*)&rep); if(num_types) { xXResType scratch; char *name; for(i = 0; i < lastResourceType; i++) { if(!counts[i]) continue; name = (char *)LookupResourceName(i + 1); if (strcmp(name, XREGISTRY_UNKNOWN)) scratch.resource_type = MakeAtom(name, strlen(name), TRUE); else { char buf[40]; snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1); scratch.resource_type = MakeAtom(buf, strlen(buf), TRUE); } scratch.count = counts[i]; if(client->swapped) { register int n; swapl (&scratch.resource_type, n); swapl (&scratch.count, n); } WriteToClient (client, sz_xXResType, (char *) &scratch); } } xfree(counts); return (client->noClientException);}
开发者ID:freedesktop-unofficial-mirror,项目名称:xorg__xprint,代码行数:73,
示例15: savecontextstatic void savecontext(void){ struct codecontext *con = xalloc(sizeof(struct codecontext)); con->next = contextbase; contextbase = con; con->head = head; con->tail = tail; con->headptr = headptr; headptr = &head; head = tail = 0; con->errfile = errfile; con->interject = interjectptr; con->line = lineno; con->errline = errlineno; con->file = infile; strcpy(con->id, lastid); con->cbautoinithead = cbautoinithead; con->cbautoinittail = cbautoinittail; con->cbautorundownhead = cbautorundownhead; con->cbautorundowntail = cbautorundowntail; cbautoinithead = 0; cbautoinittail = 0; cbautorundownhead = 0; cbautorundowntail = 0; con->blockrundown = block_rundown; con->blocknest = block_nesting; block_rundown = 0; block_nesting = 0; con->funcendstmt = funcendstmt; con->xlsyms = lsyms; con->xoldlsyms = oldlsym; con->xltags = ltags; con->xoldltags = oldltag; lsyms.head = lsyms.tail = 0; oldlsym.head = oldlsym.tail = 0; oldltag.head = oldltag.tail = 0; con->goodcode = goodcode; con->asntyp = asntyp; asntyp = 0; con->andtyp = andtyp; andtyp = 0; con->typequal = typequal; typequal = 0; con->declclass = declclass; declclass = 0; con->defaulttype = defaulttype; con->cfhold = currentfunc; currentfunc = 0; con->chhold = lastch; con->sthold = lastst; con->oldvirtual = virtualfuncs; con->vlisthead = varlisthead; varlisthead = 0; con->vlisttail = varlisttail; varlisttail = 0; con->conscount = conscount; conscount = 0; con->statictemplate = statictemplate; con->used_alloca = used_alloca; used_alloca = FALSE; con->allocaSP = allocaSP ; allocaSP = NULL; con->blockVarArraySP = blockVarArraySP ; blockVarArraySP = NULL;}
开发者ID:LADSoft,项目名称:Simple-MSIL-Compiler,代码行数:65,
示例16: XkbDDXListComponent/***====================================================================***/static StatusXkbDDXListComponent( DeviceIntPtr dev, int what, XkbSrvListInfoPtr list, ClientPtr client){char *file,*map,*tmp,*buf=NULL;FILE *in;Status status;int rval;Bool haveDir;#ifdef WIN32char tmpname[PATH_MAX];#endif if ((list->pattern[what]==NULL)||(list->pattern[what][0]=='/0')) return Success; file= list->pattern[what]; map= strrchr(file,'('); if (map!=NULL) { char *tmp; map++; tmp= strrchr(map,')'); if ((tmp==NULL)||(tmp[1]!='/0')) { /* illegal pattern. No error, but no match */ return Success; } } in= NULL; haveDir= True;#ifdef WIN32 strcpy(tmpname, Win32TempDir()); strcat(tmpname, "//xkb_XXXXXX"); (void) mktemp(tmpname);#endif if (XkbBaseDirectory!=NULL) { if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='/0')) { buf = Xprintf("%s/%s.dir",XkbBaseDirectory,componentDirs[what]); in= fopen(buf,"r"); } if (!in) { haveDir= False; buf = Xprintf( "'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg, XkbBinDirectory,XkbBaseDirectory,componentDirs[what],(long) ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), file W32_tmpfile ); } } else { if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='/0')) { buf = Xprintf("%s.dir",componentDirs[what]); in= fopen(buf,"r"); } if (!in) { haveDir= False; buf = Xprintf( "xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg, componentDirs[what],(long) ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), file W32_tmpfile ); } } status= Success; if (!haveDir) { #ifndef WIN32 in= Popen(buf,"r");#else#ifdef DEBUG_CMD ErrorF("xkb executes: %s/n",buf);#endif if (System(buf) < 0) ErrorF("Could not invoke keymap compiler/n"); else in= fopen(tmpname, "r");#endif } if (!in) { if (buf != NULL) xfree (buf);#ifdef WIN32 unlink(tmpname);#endif return BadImplementation; } list->nFound[what]= 0; if (buf) { xfree(buf); buf = NULL; } buf = xalloc(PATH_MAX * sizeof(char)); if (!buf) return BadAlloc; while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) {//.........这里部分代码省略.........
开发者ID:GrahamCobb,项目名称:maemo-xsisusb,代码行数:101,
示例17: AddExtensionExtensionEntry *AddExtension(char *name, int NumEvents, int NumErrors, int (*MainProc)(ClientPtr c1), int (*SwappedMainProc)(ClientPtr c2), void (*CloseDownProc)(ExtensionEntry *e), unsigned short (*MinorOpcodeProc)(ClientPtr c3)){ int i; register ExtensionEntry *ext, **newexts; if (!MainProc || !SwappedMainProc || !CloseDownProc || !MinorOpcodeProc) return((ExtensionEntry *) NULL); if ((lastEvent + NumEvents > LAST_EVENT) || (unsigned)(lastError + NumErrors > LAST_ERROR)) return((ExtensionEntry *) NULL); ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry)); if (!ext) return((ExtensionEntry *) NULL); ext->name = (char *)xalloc(strlen(name) + 1); ext->num_aliases = 0; ext->aliases = (char **)NULL; if (!ext->name) { xfree(ext); return((ExtensionEntry *) NULL); } strcpy(ext->name, name); i = NumExtensions; newexts = (ExtensionEntry **) xrealloc(extensions, (i + 1) * sizeof(ExtensionEntry *)); if (!newexts) { xfree(ext->name); xfree(ext); return((ExtensionEntry *) NULL); } NumExtensions++; extensions = newexts; extensions[i] = ext; ext->index = i; ext->base = i + EXTENSION_BASE; ext->CloseDown = CloseDownProc; ext->MinorOpcode = MinorOpcodeProc; ProcVector[i + EXTENSION_BASE] = MainProc; SwappedProcVector[i + EXTENSION_BASE] = SwappedMainProc; if (NumEvents) { ext->eventBase = lastEvent; ext->eventLast = lastEvent + NumEvents; lastEvent += NumEvents; } else { ext->eventBase = 0; ext->eventLast = 0; } if (NumErrors) { ext->errorBase = lastError; ext->errorLast = lastError + NumErrors; lastError += NumErrors; } else { ext->errorBase = 0; ext->errorLast = 0; }#ifdef XCSECURITY ext->secure = FALSE;#endif#ifdef LBX (void) LbxAddExtension(name, ext->base, ext->eventBase, ext->errorBase);#endif return(ext);}
开发者ID:theqvd,项目名称:qvd-nx-libs-3.5.0-32,代码行数:77,
示例18: PclPolySegmentvoidPclPolySegment( DrawablePtr pDrawable, GCPtr pGC, int nSegments, xSegment *pSegments){ FILE *outFile, *dummy; char t[80]; int xoffset, yoffset; int nbox, i; unsigned long valid; BoxPtr pbox; xRectangle *drawRects, *r; RegionPtr drawRegion, region; short fudge; XpContextPtr pCon; PclContextPrivPtr pConPriv; GC cacheGC; if( PclUpdateDrawableGC( pGC, pDrawable, &outFile ) == FALSE ) return; pCon = PclGetContextFromWindow( (WindowPtr) pDrawable ); pConPriv = (PclContextPrivPtr) pCon->devPrivates[PclContextPrivateIndex].ptr; /* * Allocate the storage for the temporary regions. */ region = REGION_CREATE( pGC->pScreen, NULL, 0 ); drawRects = (xRectangle *) xalloc( nSegments * sizeof( xRectangle ) ); /* * Calculate the fudge factor, based on the line width */ fudge = pGC->lineWidth * 3 + 1; /* * Turn off line joining. */ SEND_PCL( outFile, "/033%0BLA2,6;/033%0A" ); /* * Generate the PCL code to draw the segments, by defining them as * a macro which uses the HP-GL/2 line drawing function. * * XXX I wonder if this should be implemented using the Encoded * XXX Polyline function. Since I'm only sending it once, it's not * XXX necessarily too important. */ MACRO_START( outFile, pConPriv ); SAVE_PCL( outFile, pConPriv, "/033%0B" ); xoffset = pDrawable->x; yoffset = pDrawable->y; for( i = 0, r = drawRects; i < nSegments; i++, r++ ) { r->x = MIN( pSegments[i].x1, pSegments[i].x2 ) + xoffset; r->y = MIN( pSegments[i].y1, pSegments[i].y2 ) + yoffset; r->width = abs( pSegments[i].x1 - pSegments[i].x2 ); r->height = abs( pSegments[i].y1 - pSegments[i].y2 ); sprintf( t, "PU%d,%d;PD%d,%d;", pSegments[i].x1 + xoffset, pSegments[i].y1 + yoffset, pSegments[i].x2 + xoffset, pSegments[i].y2 + yoffset ); SAVE_PCL( outFile, pConPriv, t ); r->x -= fudge; r->y -= fudge; r->width += 2 * fudge; r->height += 2 * fudge; } SAVE_PCL( outFile, pConPriv, "/033%0A" ); MACRO_END ( outFile ); /* * Convert the collection of rectangles into a proper region, then * intersect it with the clip region. */ drawRegion = RECTS_TO_REGION( pGC->pScreen, nSegments, drawRects, CT_UNSORTED ); REGION_INTERSECT( pGC->pScreen, region, drawRegion, pGC->pCompositeClip ); /* * For each rectangle in the clip region, set the HP-GL/2 "input * window" and render the entire set of segments to it. */ pbox = REGION_RECTS( region ); nbox = REGION_NUM_RECTS( region ); PclSendData(outFile, pConPriv, pbox, nbox, 1.0); /* * Now we need to reset the line join mode to whatever it was at before. * The easiest way is to force the cached GC's joinstyle to be different//.........这里部分代码省略.........
开发者ID:aosm,项目名称:X11,代码行数:101,
示例19: allocatevoid allocate(int datareg, int addreg, int floatreg, SNODE *block )/* * allocate will allocate registers for the expressions that have * a high enough desirability. */{ CSE *csp; ENODE *exptr; unsigned mask, rmask,i,fmask,frmask,size; AMODE *ap, *ap2; framedepth = 4+lc_maxauto; mask = 0; rmask = 0; fmask = frmask = 0; for (i=cf_freedata; i < datareg; i++) { framedepth+=4; rmask = rmask | (1 << (15 - i)); mask = mask | (1 << i); } for (i=cf_freeaddress+16; i < addreg; i++) { framedepth+=4; rmask = rmask | (1 << (23 - i)); mask = mask | (1 << (i-8)); } while( bsort(&olist) ); /* sort the expression list */ csp = olist; while( csp != 0 ) { if (csp->reg == -1 && !(csp->exp->cflags & DF_VOL) && !csp->voidf) { if( desire(csp) < 3 ) csp->reg = -1; else { if (csp->exp->nodetype == en_rcon || csp->exp->nodetype == en_fcon || csp->exp->nodetype == en_lrcon || csp->exp->nodetype == en_floatref || csp->exp->nodetype ==en_doubleref || csp->exp->nodetype == en_longdoubleref) { if (floatreg <24 && floatregs) csp->reg = floatreg++; } else if( (datareg < cf_maxdata) && (csp->duses <= csp->uses/4) && dataregs) csp->reg = (datareg)++; else if( !(csp->size == 1 || csp->size == -1) && (addreg < cf_maxaddress) &&addrregs) csp->reg = (addreg)++; } } if( csp->reg != -1 ) { if (lvalue(csp->exp) && !((SYM *)csp->exp->v.p[0]->v.p[0])->funcparm) { ((SYM *)csp->exp->v.p[0]->v.p[0])->inreg = TRUE; ((SYM *)csp->exp->v.p[0]->v.p[0])->value.i = -csp->reg; } if (csp->reg < 16) { framedepth+=4; rmask = rmask | (1 << (15 - csp->reg)); mask = mask | (1 << csp->reg); } else if (csp->reg < 32) { framedepth+=4; rmask = rmask | (1 << (23 - csp->reg)); mask = mask | (1 << (csp->reg-8)); } else { framedepth+=12; frmask = frmask | (1 << (39 - csp->reg)); fmask = fmask | (1 << (csp->reg-32)); } } csp = csp->next; } allocstack(); /* Allocate stack space for the local vars */ if (currentfunc->tp->lst.head !=0 && currentfunc->tp->lst.head != (SYM *)-1) { if (prm_phiform || currentfunc->intflag) { mask |= (1 << (linkreg +8)); rmask |= (1 << (15 - linkreg -8)); framedepth+=4; } if (currentfunc->intflag) { mask |= 0xffff; rmask |= 0xffff; framedepth = lc_maxauto; } } if (prm_linkreg && !currentfunc->intflag && (currentfunc->tp->lst.head && currentfunc->tp->lst.head != (SYM *)-1 || lc_maxauto)) { gen_code(op_link,0,makeareg(linkreg),make_immed(-lc_maxauto)); } if( mask != 0 ) gen_code(op_movem,4,make_mask(rmask,0,0),push); save_mask = mask; if (fmask!=0) gen_code(op_fmovem,10,make_mask(frmask,0,1),push); fsave_mask = fmask; if ((prm_phiform || currentfunc->intflag) && currentfunc->tp->lst.head && currentfunc->tp->lst.head != (SYM *) -1) { gen_code(op_move,4,makeareg(0), makeareg(linkreg)); } if ((!prm_linkreg || currentfunc->intflag) && lc_maxauto) { AMODE *ap = xalloc(sizeof(AMODE)); ap->mode = am_indx; ap->offset = makenode(en_icon,(char *)-lc_maxauto,0); ap->preg = 7; gen_code(op_lea,0,ap,makeareg(7)); } if (prm_stackcheck) {//.........这里部分代码省略.........
开发者ID:BGCX261,项目名称:zlmtank-svn-to-git,代码行数:101,
示例20: test_cipher_ctrvoidtest_cipher_ctr(const struct nettle_cipher *cipher, const struct tstring *key, const struct tstring *cleartext, const struct tstring *ciphertext, const struct tstring *ictr){ void *ctx = xalloc(cipher->context_size); uint8_t *data; uint8_t *ctr = xalloc(cipher->block_size); uint8_t *octr = xalloc(cipher->block_size); unsigned length; unsigned low, nblocks; ASSERT (cleartext->length == ciphertext->length); length = cleartext->length; ASSERT (ictr->length == cipher->block_size); /* Compute expected counter value after the operation. */ nblocks = (length + cipher->block_size - 1) / cipher->block_size; ASSERT (nblocks < 0x100); memcpy (octr, ictr->data, cipher->block_size - 1); low = ictr->data[cipher->block_size - 1] + nblocks; octr[cipher->block_size - 1] = low; if (low >= 0x100) INCREMENT (cipher->block_size - 1, octr); data = xalloc(length); cipher->set_encrypt_key(ctx, key->length, key->data); memcpy(ctr, ictr->data, cipher->block_size); ctr_crypt(ctx, cipher->encrypt, cipher->block_size, ctr, length, data, cleartext->data); if (!MEMEQ(length, data, ciphertext->data)) { fprintf(stderr, "CTR encrypt failed:/nInput:"); tstring_print_hex(cleartext); fprintf(stderr, "/nOutput: "); print_hex(length, data); fprintf(stderr, "/nExpected:"); tstring_print_hex(ciphertext); fprintf(stderr, "/n"); FAIL(); } ASSERT (MEMEQ (cipher->block_size, ctr, octr)); memcpy(ctr, ictr->data, cipher->block_size); ctr_crypt(ctx, cipher->encrypt, cipher->block_size, ctr, length, data, data); if (!MEMEQ(length, data, cleartext->data)) { fprintf(stderr, "CTR decrypt failed:/nInput:"); tstring_print_hex(ciphertext); fprintf(stderr, "/nOutput: "); print_hex(length, data); fprintf(stderr, "/nExpected:"); tstring_print_hex(cleartext); fprintf(stderr, "/n"); FAIL(); } ASSERT (MEMEQ (cipher->block_size, ctr, octr)); free(ctx); free(data); free(octr); free(ctr);}
开发者ID:AllardJ,项目名称:Tomato,代码行数:78,
示例21: i82365probestatic I82365*i82365probe(int x, int d, int dev){ uchar c, id; I82365 *cp; ISAConf isa; int i, nslot; outb(x, Rid + (dev<<7)); id = inb(d); if((id & 0xf0) != 0x80) return 0; /* not a memory & I/O card */ if((id & 0x0f) == 0x00) return 0; /* no revision number, not possible */ cp = xalloc(sizeof(I82365)); cp->xreg = x; cp->dreg = d; cp->dev = dev; cp->type = Ti82365; cp->nslot = 2; switch(id){ case 0x82: case 0x83: case 0x84: /* could be a cirrus */ outb(x, Rchipinfo + (dev<<7)); outb(d, 0); c = inb(d); if((c & 0xc0) != 0xc0) break; c = inb(d); if((c & 0xc0) != 0x00) break; if(c & 0x20){ cp->type = Tpd6720; } else { cp->type = Tpd6710; cp->nslot = 1; } /* low power mode */ outb(x, Rmisc2 + (dev<<7)); c = inb(d); outb(d, c & ~Flowpow); break; } /* if it's not a Cirrus, it could be a Vadem... */ if(cp->type == Ti82365){ /* unlock the Vadem extended regs */ outb(x, 0x0E + (dev<<7)); outb(x, 0x37 + (dev<<7)); /* make the id register show the Vadem id */ outb(x, 0x3A + (dev<<7)); c = inb(d); outb(d, c|0xC0); outb(x, Rid + (dev<<7)); c = inb(d); if(c & 0x08) cp->type = Tvg46x; /* go back to Intel compatible id */ outb(x, 0x3A + (dev<<7)); c = inb(d); outb(d, c & ~0xC0); } memset(&isa, 0, sizeof(ISAConf)); if(isaconfig("pcmcia", ncontroller, &isa) && isa.irq) cp->irq = isa.irq; else cp->irq = IrqPCMCIA; for(i = 0; i < isa.nopt; i++){ if(cistrncmp(isa.opt[i], "nslot=", 6)) continue; nslot = strtol(&isa.opt[i][6], nil, 0); if(nslot > 0 && nslot <= 2) cp->nslot = nslot; } controller[ncontroller++] = cp; return cp;}
开发者ID:CoryXie,项目名称:NxM,代码行数:87,
示例22: xalloc_limbsmp_limb_t *xalloc_limbs (mp_size_t n){ return xalloc (n * sizeof (mp_limb_t));}
开发者ID:AllardJ,项目名称:Tomato,代码行数:5,
示例23: devi82365link/* * set up for slot cards */voiddevi82365link(void){ static int already; int i, j; I82365 *cp; PCMslot *pp; char buf[32], *p; if(already) return; already = 1; if((p=getconf("pcmcia0")) && strncmp(p, "disabled", 8)==0) return; if(_pcmspecial) return; /* look for controllers if the ports aren't already taken */ if(ioalloc(0x3E0, 2, 0, "i82365.0") >= 0){ i82365probe(0x3E0, 0x3E1, 0); i82365probe(0x3E0, 0x3E1, 1); if(ncontroller == 0) iofree(0x3E0); } if(ioalloc(0x3E2, 2, 0, "i82365.1") >= 0){ i = ncontroller; i82365probe(0x3E2, 0x3E3, 0); i82365probe(0x3E2, 0x3E3, 1); if(ncontroller == i) iofree(0x3E2); } if(ncontroller == 0) return; _pcmspecial = pcmcia_pcmspecial; _pcmspecialclose = pcmcia_pcmspecialclose; for(i = 0; i < ncontroller; i++) nslot += controller[i]->nslot; slot = xalloc(nslot * sizeof(PCMslot)); lastslot = slot; for(i = 0; i < ncontroller; i++){ cp = controller[i]; print("#y%d: %d slot %s: port 0x%uX irq %d/n", i, cp->nslot, chipname[cp->type], cp->xreg, cp->irq); for(j = 0; j < cp->nslot; j++){ pp = lastslot++; pp->slotno = pp - slot; pp->memlen = 64*MB; pp->base = (cp->dev<<7) | (j<<6); pp->cp = cp; pp->msec = ~0; pp->verstr[0] = 0; slotdis(pp); /* interrupt on status change */ wrreg(pp, Rcscic, (cp->irq<<4) | Fchangeena); rdreg(pp, Rcsc); } /* for card management interrupts */ snprint(buf, sizeof buf, "i82365.%d", i); intrenable(cp->irq, i82365intr, 0, BUSUNKNOWN, buf); }}
开发者ID:CoryXie,项目名称:NxM,代码行数:72,
示例24: MultibufferExtensionInitvoidMultibufferExtensionInit(){ ExtensionEntry *extEntry; int i, j; ScreenPtr pScreen; MultibufferScreenPtr pMultibufferScreen; /* * allocate private pointers in windows and screens. Allocating * window privates may seem like an unnecessary expense, but every * PositionWindow call must check to see if the window is * multi-buffered; a resource lookup is too expensive. */ MultibufferScreenIndex = AllocateScreenPrivateIndex (); if (MultibufferScreenIndex < 0) return; MultibufferWindowIndex = AllocateWindowPrivateIndex (); for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; if (!AllocateWindowPrivate (pScreen, MultibufferWindowIndex, 0) || !(pMultibufferScreen = (MultibufferScreenPtr) xalloc (sizeof (MultibufferScreenRec)))) { for (j = 0; j < i; j++) xfree (screenInfo.screens[j]->devPrivates[MultibufferScreenIndex].ptr); return; } pScreen->devPrivates[MultibufferScreenIndex].ptr = (pointer) pMultibufferScreen; /* * wrap PositionWindow to resize the pixmap when the window * changes size */ pMultibufferScreen->PositionWindow = pScreen->PositionWindow; pScreen->PositionWindow = MultibufferPositionWindow; } /* * create the resource types */ MultibufferDrawableResType = CreateNewResourceType(MultibufferDrawableDelete)|RC_CACHED|RC_DRAWABLE; MultibufferResType = CreateNewResourceType(MultibufferDelete); MultibuffersResType = CreateNewResourceType(MultibuffersDelete); OtherClientResType = CreateNewResourceType(OtherClientDelete); if (MultibufferDrawableResType && MultibufferResType && MultibuffersResType && OtherClientResType && (extEntry = AddExtension(MULTIBUFFER_PROTOCOL_NAME, MultibufferNumberEvents, MultibufferNumberErrors, ProcMultibufferDispatch, SProcMultibufferDispatch, MultibufferResetProc, StandardMinorOpcode))) {#if 0 MultibufferReqCode = (unsigned char)extEntry->base;#endif MultibufferEventBase = extEntry->eventBase; MultibufferErrorBase = extEntry->errorBase; EventSwapVector[MultibufferEventBase + MultibufferClobberNotify] = (EventSwapPtr) SClobberNotifyEvent; EventSwapVector[MultibufferEventBase + MultibufferUpdateNotify] = (EventSwapPtr) SUpdateNotifyEvent; }}
开发者ID:GrahamCobb,项目名称:maemo-xsisusb,代码行数:61,
示例25: FindModulestatic char *FindModule(const char *module, const char *dir, const char **subdirlist, PatternPtr patterns){ char buf[PATH_MAX + 1]; char *dirpath = NULL; char *name = NULL; struct stat stat_buf; int len, dirlen; char *fp; DIR *d; const char **subdirs = NULL; PatternPtr p = NULL; const char **s; struct dirent *dp; regmatch_t match[2]; subdirs = InitSubdirs(subdirlist); if (!subdirs) return NULL;#ifndef __EMX__ dirpath = (char *)dir;#else dirpath = xalloc(strlen(dir) + 10); strcpy(dirpath, (char *)__XOS2RedirRoot(dir));#endif if (strlen(dirpath) > PATH_MAX) return NULL; /*xf86Msg(X_INFO,"OS2DIAG: FindModule: dirpath=%s/n",dirpath); */ for (s = subdirs; *s; s++) { if ((dirlen = strlen(dirpath) + strlen(*s)) > PATH_MAX) continue; strcpy(buf, dirpath); strcat(buf, *s); /*xf86Msg(X_INFO,"OS2DIAG: FindModule: buf=%s/n",buf); */ fp = buf + dirlen; if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) && (d = opendir(buf))) { if (buf[dirlen - 1] != '/') { buf[dirlen++] = '/'; fp++; } while ((dp = readdir(d))) { if (dirlen + strlen(dp->d_name) + 1 > PATH_MAX) continue; strcpy(fp, dp->d_name); if (!(stat(buf, &stat_buf) == 0 && S_ISREG(stat_buf.st_mode))) continue; for (p = patterns; p->pattern; p++) { if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 && match[1].rm_so != -1) { len = match[1].rm_eo - match[1].rm_so; if (len == strlen(module) && strncmp(module, dp->d_name + match[1].rm_so, len) == 0) { /*xf86Msg(X_INFO,"OS2DIAG: matching %s/n",buf); */ name = buf; break; } } } if (name) break; } closedir(d); if (name) break; } } FreeSubdirs(subdirs); if (dirpath != dir) xfree(dirpath); if (name) { return xstrdup(name); } return NULL;}
开发者ID:marioaugustorama,项目名称:tropix-xwindow,代码行数:80,
示例26: build_event_list_and_beat_list_from_inputEvent * build_event_list_and_beat_list_from_input(void) { char first_part[100]; int second_part; int third_part; int fourth_part; int event_time; int N_parts; int on_event, both_event, off_event; int on_time, off_time; int i; Pitch pitch; Event * event_list, * new_event; Beat * new_beat; beatlevel[0].count = 1; beatlevel[0].start = 0; beatlevel[0].units = 1; N_beatlevel = 1; event_time = 0; event_list = NULL; global_beat_list = NULL; for (line_no = 1; fgets(line, sizeof(line), instream) != NULL; line_no++) { for (i=0; isspace(line[i]); i++); if (line[i] == '%' || line[i] == '/0') continue; /* ignore comment lines */ N_parts = sscanf(line, "%99s %d %d %d", first_part, &second_part, &third_part, &fourth_part); if (N_parts < 2) { warn(); continue; } if (strcasecmp(first_part, "BaseUnit") == 0) { if (N_parts != 2) { fprintf(stderr, "%s: Error (line %d) BaseUnit expects one integer parameter./n", this_program, line_no); my_exit(1); } baseunit = second_part; continue; } if (strcasecmp(first_part, "BeatLevel") == 0) { if (N_parts != 4) { fprintf(stderr, "%s: Error (line %d) BeatLevel expects three integer parameters./n", this_program, line_no); my_exit(1); } if (N_beatlevel != second_part) { fprintf(stderr, "%s: Error (line %d) A BeatLevel numbers must be in increasing order"/ " starting from 1./n", this_program, line_no); my_exit(1); } if (N_beatlevel+1 > MAX_BEAT_LEVEL) { fprintf(stderr, "%s: Error (line %d) A BeatLevel cannot be greater than %d/n", this_program, line_no, MAX_BEAT_LEVEL); my_exit(1); } beatlevel[N_beatlevel].count = third_part; beatlevel[N_beatlevel].start = fourth_part; beatlevel[N_beatlevel].units = beatlevel[N_beatlevel].count * beatlevel[N_beatlevel-1].units; if (verbosity >= 3) { printf(" beatlevel[%d].count(start)(units) =%d (%d)(%d)/n", N_beatlevel, third_part, fourth_part, beatlevel[N_beatlevel].units); } N_beatlevel++; continue; } if (strcasecmp(first_part, "Beat") == 0) { new_beat = (Beat *) xalloc(sizeof(Beat)); new_beat->start = second_part; new_beat->level = third_part; if(print_beats) printf("Beat %6d %2d/n", new_beat->start, new_beat->level); new_beat->next = global_beat_list; global_beat_list = new_beat; if (new_beat->level+1 > N_beatlevel) N_beatlevel = new_beat->level+1; continue; } on_event = (strcasecmp(first_part, "Note-on") == 0); both_event = (strcasecmp(first_part, "Note") == 0); off_event = (strcasecmp(first_part, "Note-off") == 0); if (!(on_event || off_event || both_event)) { warn(); continue; }//.........这里部分代码省略.........
开发者ID:kroger,项目名称:rameau,代码行数:101,
示例27: ProcAppleWMSelectInputstatic intProcAppleWMSelectInput (register ClientPtr client){ REQUEST(xAppleWMSelectInputReq); WMEventPtr pEvent, pNewEvent, *pHead; XID clientResource; int i; REQUEST_SIZE_MATCH (xAppleWMSelectInputReq); i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, client, DixWriteAccess); if (stuff->mask != 0) { if (i == Success && pHead) { /* check for existing entry. */ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) { if (pEvent->client == client) { pEvent->mask = stuff->mask; updateEventMask (pHead); return Success; } } } /* build the entry */ pNewEvent = (WMEventPtr) xalloc (sizeof (WMEventRec)); if (!pNewEvent) return BadAlloc; pNewEvent->next = 0; pNewEvent->client = client; pNewEvent->mask = stuff->mask; /* * add a resource that will be deleted when * the client goes away */ clientResource = FakeClientID (client->index); pNewEvent->clientResource = clientResource; if (!AddResource (clientResource, ClientType, (pointer)pNewEvent)) return BadAlloc; /* * create a resource to contain a pointer to the list * of clients selecting input. This must be indirect as * the list may be arbitrarily rearranged which cannot be * done through the resource database. */ if (i != Success || !pHead) { pHead = (WMEventPtr *) xalloc (sizeof (WMEventPtr)); if (!pHead || !AddResource (eventResource, EventType, (pointer)pHead)) { FreeResource (clientResource, RT_NONE); return BadAlloc; } *pHead = 0; } pNewEvent->next = *pHead; *pHead = pNewEvent; updateEventMask (pHead); } else if (stuff->mask == 0) { /* delete the interest */ if (i == Success && pHead) { pNewEvent = 0; for (pEvent = *pHead; pEvent; pEvent = pEvent->next) { if (pEvent->client == client) break; pNewEvent = pEvent; } if (pEvent) { FreeResource (pEvent->clientResource, ClientType); if (pNewEvent) pNewEvent->next = pEvent->next; else *pHead = pEvent->next; xfree (pEvent); updateEventMask (pHead); } } } else { client->errorValue = stuff->mask; return BadValue; } return Success;}
开发者ID:hush-z,项目名称:VMGL,代码行数:84,
注:本文中的xalloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xalloc_die函数代码示例 C++ xaccTransBeginEdit函数代码示例 |