本文整理汇总了C++中xalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ xalloc函数的具体用法?C++ xalloc怎么用?C++ xalloc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xalloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xf86RandR12CrtcSet
static Bool
xf86RandR12CrtcSet (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;
//.........这里部分代码省略.........
示例2: test_eddsa_sign
#include "testutils.h"
#include "eddsa.h"
#include "eddsa-internal.h"
static void
test_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))
示例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);
//.........这里部分代码省略.........
示例4: PclPolyLine
void
PclPolyLine(
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
//.........这里部分代码省略.........
示例5: test_cipher_stream
void
test_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);
}
示例6: IntervalListCreateSet
static RecordSetPtr
IntervalListCreateSet(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;
}
示例7: XAAValidateGC
static void
XAAValidateGC(
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;
}
//.........这里部分代码省略.........
示例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){
示例9: verify_auth_info
int
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')
//.........这里部分代码省略.........
示例10: xf86CrtcRotate
_X_EXPORT Bool
xf86CrtcRotate (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) {
//.........这里部分代码省略.........
示例11: restricted_expression
Exp * 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;
//.........这里部分代码省略.........
示例12: ProcXDGAQueryModes
static int
ProcXDGAQueryModes(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);
}
示例13: xf86RandR12SetInfo12
/*
* Mirror the current mode configuration to RandR
*/
static Bool
xf86RandR12SetInfo12 (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;
}
示例14: ProcXResQueryClientResources
static int
ProcXResQueryClientResources (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);
}
示例15: savecontext
static 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;
}