summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2006-11-27 18:07:16 +1030
committerPeter Hutterer <whot@hyena.localdomain>2006-11-27 18:07:16 +1030
commit85ea408e38f452bcf9109f14fd1016d159692a99 (patch)
tree3cece3f429bf60129f926aca69002823b5d73da1 /mi
parent023da4e804ad260eaf0c50d2ec7213dd514e2113 (diff)
mi: malloc checks for misprite and midispcur, code cleanup
removed IsMPDev()
Diffstat (limited to 'mi')
-rw-r--r--mi/midispcur.c40
-rw-r--r--mi/mipointer.c7
-rw-r--r--mi/misprite.c108
3 files changed, 72 insertions, 83 deletions
diff --git a/mi/midispcur.c b/mi/midispcur.c
index 514fae88d..0b4ef49d6 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -139,6 +139,7 @@ miDCInitialize (pScreen, screenFuncs)
miPointerScreenFuncPtr screenFuncs;
{
miDCScreenPtr pScreenPriv;
+ miDCBufferPtr pBuffer;
if (miDCGeneration != serverGeneration)
{
@@ -154,36 +155,33 @@ miDCInitialize (pScreen, screenFuncs)
/*
* initialize the entire private structure to zeros
*/
+#if !defined MPX
pScreenPriv->pCoreBuffer = (miDCBufferPtr)xalloc(sizeof(miDCBufferRec));
-
- pScreenPriv->pCoreBuffer->pSourceGC =
- pScreenPriv->pCoreBuffer->pMaskGC =
- pScreenPriv->pCoreBuffer->pSaveGC =
- pScreenPriv->pCoreBuffer->pRestoreGC =
- pScreenPriv->pCoreBuffer->pMoveGC =
- pScreenPriv->pCoreBuffer->pPixSourceGC =
- pScreenPriv->pCoreBuffer->pPixMaskGC = NULL;
-#ifdef ARGB_CURSOR
- pScreenPriv->pCoreBuffer->pRootPicture = NULL;
- pScreenPriv->pCoreBuffer->pTempPicture = NULL;
-#endif
-
- pScreenPriv->pCoreBuffer->pSave = pScreenPriv->pCoreBuffer->pTemp = NULL;
-
-#ifdef MPX
+ if (!pScreenPriv->pCoreBuffer)
+ {
+ xfree((pointer)pScreenPriv);
+ return FALSE;
+ }
+ pBuffer = pScreenPriv->pCoreBuffer;
+#else /* ifdef MPX */
{
int mpBufferIdx = 0;
pScreenPriv->pMPBuffers = (miDCBufferPtr)xalloc(MAX_DEVICES *
sizeof(miDCBufferRec));
-
+ if (!pScreenPriv->pMPBuffers)
+ {
+ xfree((pointer)pScreenPriv);
+ return FALSE;
+ }
+
/* virtual core pointer ID is 1 */
- xfree(pScreenPriv->pCoreBuffer);
pScreenPriv->pCoreBuffer = &pScreenPriv->pMPBuffers[1];
- while (mpBufferIdx < MAX_DEVICES)
+ while(mpBufferIdx < MAX_DEVICES)
{
- miDCBufferPtr pBuffer = &pScreenPriv->pMPBuffers[mpBufferIdx];
+ pBuffer = &pScreenPriv->pMPBuffers[mpBufferIdx];
+#endif
pBuffer->pSourceGC =
pBuffer->pMaskGC =
pBuffer->pSaveGC =
@@ -198,11 +196,13 @@ miDCInitialize (pScreen, screenFuncs)
pBuffer->pSave = pBuffer->pTemp = NULL;
+#ifdef MPX
mpBufferIdx++;
}
}
#endif
+
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = miDCCloseScreen;
diff --git a/mi/mipointer.c b/mi/mipointer.c
index db9a6f888..6ccc7299d 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -71,13 +71,6 @@ static miPointerPtr miPointer;
*/
static miPointerRec miMPPointers[MAX_DEVICES];
-
-/* Check if the given device is a MP device. */
-_X_EXPORT Bool
-IsMPDev(DeviceIntPtr pDev)
-{
- return (pDev && pDev->isMPDev && pDev->id < MAX_DEVICES);
-}
#endif
static Bool miPointerRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
diff --git a/mi/misprite.c b/mi/misprite.c
index e51599e63..ec90ad2dc 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -187,11 +187,9 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
miSpriteCursorFuncPtr cursorFuncs;
miPointerScreenFuncPtr screenFuncs;
{
-#ifdef MPX
- int mpCursorIdx = 0;
-#endif
miSpriteScreenPtr pScreenPriv;
VisualPtr pVisual;
+ miCursorInfoPtr pCursorInfo;
if (!DamageSetup (pScreen))
return FALSE;
@@ -239,73 +237,71 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
pScreenPriv->BlockHandler = pScreen->BlockHandler;
+#if !defined MPX
pScreenPriv->cp = (miCursorInfoPtr)xalloc(sizeof(miCursorInfoRec));
- pScreenPriv->cp->pCursor = NULL;
- pScreenPriv->cp->x = 0;
- pScreenPriv->cp->y = 0;
- pScreenPriv->cp->isUp = FALSE;
- pScreenPriv->cp->shouldBeUp = FALSE;
- pScreenPriv->cp->pCacheWin = NullWindow;
- pScreenPriv->cp->isInCacheWin = FALSE;
- pScreenPriv->cp->checkPixels = TRUE;
- pScreenPriv->cp->pInstalledMap = NULL;
- pScreenPriv->cp->pColormap = NULL;
- pScreenPriv->cp->colors[SOURCE_COLOR].red = 0;
- pScreenPriv->cp->colors[SOURCE_COLOR].green = 0;
- pScreenPriv->cp->colors[SOURCE_COLOR].blue = 0;
- pScreenPriv->cp->colors[MASK_COLOR].red = 0;
- pScreenPriv->cp->colors[MASK_COLOR].green = 0;
- pScreenPriv->cp->colors[MASK_COLOR].blue = 0;
+ if (!pScreenPriv->cp)
+ {
+ xfree((pointer)pScreenPriv);
+ return FALSE;
+ }
+ pCursorInfo = pScreenPriv->cp;
+#else
+ /* alloc and zero memory for all MPX cursors */
+ pScreenPriv->mpCursors = (miCursorInfoPtr)xalloc(MAX_DEVICES * sizeof(miCursorInfoRec));
+ if (!pScreenPriv->mpCursors)
+ {
+ xfree((pointer)pScreenPriv->cp);
+ xfree((pointer)pScreenPriv);
+ return FALSE;
+ }
+ pScreenPriv->cp = &(pScreenPriv->mpCursors[1]);
+
+ {
+ int mpCursorIdx = 0;
+ while (mpCursorIdx < MAX_DEVICES)
+ {
+ pCursorInfo = &(pScreenPriv->mpCursors[mpCursorIdx]);
+#endif
+
+ pCursorInfo->pCursor = NULL;
+ pCursorInfo->x = 0;
+ pCursorInfo->y = 0;
+ pCursorInfo->isUp = FALSE;
+ pCursorInfo->shouldBeUp = FALSE;
+ pCursorInfo->pCacheWin = NullWindow;
+ pCursorInfo->isInCacheWin = FALSE;
+ pCursorInfo->checkPixels = TRUE;
+ pCursorInfo->pInstalledMap = NULL;
+ pCursorInfo->pColormap = NULL;
+ pCursorInfo->colors[SOURCE_COLOR].red = 0;
+ pCursorInfo->colors[SOURCE_COLOR].green = 0;
+ pCursorInfo->colors[SOURCE_COLOR].blue = 0;
+ pCursorInfo->colors[MASK_COLOR].red = 0;
+ pCursorInfo->colors[MASK_COLOR].green = 0;
+ pCursorInfo->colors[MASK_COLOR].blue = 0;
+
+#ifdef MPX
+ mpCursorIdx++;
+ }
+ }
+#endif
pScreenPriv->funcs = cursorFuncs;
pScreen->devPrivates[miSpriteScreenIndex].ptr = (pointer) pScreenPriv;
-
+
pScreen->CloseScreen = miSpriteCloseScreen;
pScreen->GetImage = miSpriteGetImage;
pScreen->GetSpans = miSpriteGetSpans;
pScreen->SourceValidate = miSpriteSourceValidate;
-
+
pScreen->CopyWindow = miSpriteCopyWindow;
-
+
pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas;
-
+
pScreen->InstallColormap = miSpriteInstallColormap;
pScreen->StoreColors = miSpriteStoreColors;
pScreen->BlockHandler = miSpriteBlockHandler;
-
-#ifdef MPX
- /* alloc and zero memory for all MPX cursors */
- pScreenPriv->mpCursors = (miCursorInfoPtr)xalloc(MAX_DEVICES * sizeof(miCursorInfoRec));
- while (mpCursorIdx < MAX_DEVICES)
- {
- miCursorInfoPtr cursor = &(pScreenPriv->mpCursors[mpCursorIdx]);
-
- cursor->id = mpCursorIdx;
- cursor->pCursor = NULL;
- cursor->x = 0;
- cursor->y = 0;
- cursor->isUp = FALSE;
- cursor->shouldBeUp = FALSE;
- cursor->pCacheWin = NullWindow;
- cursor->isInCacheWin = FALSE;
- cursor->checkPixels = TRUE;
- cursor->pInstalledMap = NULL;
- cursor->pColormap = NULL;
- cursor->colors[SOURCE_COLOR].red = 0;
- cursor->colors[SOURCE_COLOR].green = 0;
- cursor->colors[SOURCE_COLOR].blue = 0;
- cursor->colors[MASK_COLOR].red = 0;
- cursor->colors[MASK_COLOR].green = 0;
- cursor->colors[MASK_COLOR].blue = 0;
-
- mpCursorIdx++;
- }
-
- /* virtual core pointer has id 1, we might as well save the memory */
- xfree(pScreenPriv->cp);
- pScreenPriv->cp = &(pScreenPriv->mpCursors[1]);
-#endif
damageRegister = 0;