mi: malloc checks for misprite and midispcur, code cleanup
removed IsMPDev()
This commit is contained in:
		
							parent
							
								
									023da4e804
								
							
						
					
					
						commit
						85ea408e38
					
				
							
								
								
									
										16
									
								
								Changelog
								
								
								
								
							
							
						
						
									
										16
									
								
								Changelog
								
								
								
								
							|  | @ -14,12 +14,24 @@ Files: | |||
| 
 | ||||
| ____________________________________________________________ | ||||
| 
 | ||||
| mi:     mipointer.c cleanup, reducing code duplication, using MPHasCursor() | ||||
| 	instead of IsMPDev() | ||||
| mi:     mipointer.c cleanup, reducing code duplication, using MPHasCursor(), | ||||
| 	removing IsMPDev() | ||||
| 
 | ||||
| Files: | ||||
| 	mi/mipointer.c | ||||
| 
 | ||||
| ____________________________________________________________ | ||||
| 
 | ||||
| mi:     malloc checks for misprite and midispcur, code cleanup | ||||
| 	removed IsMPDev() | ||||
| 
 | ||||
| Files: | ||||
| 	mi/misprite.c | ||||
| 	mi/mipointer.c | ||||
| 	mi/midispcur.c | ||||
| 	dix/events.c | ||||
| 
 | ||||
| 
 | ||||
| == 23.11.06 == | ||||
| mi:	closing memory leak, miPointer is freed in miPointerCloseScreen | ||||
| 	bugfix: uninitialized pPointer in miPointerGetPosition ifndef MPX | ||||
|  |  | |||
							
								
								
									
										40
									
								
								dix/events.c
								
								
								
								
							
							
						
						
									
										40
									
								
								dix/events.c
								
								
								
								
							|  | @ -259,9 +259,9 @@ typedef struct { | |||
| static SpritePtr sprite;		/* info about the cursor sprite */ | ||||
| 
 | ||||
| #ifdef MPX | ||||
| static SpritePtr mpsprites;             /* info about the MPX sprites */ | ||||
| #define MPXDBG(...) fprintf (stderr, "MPX: " __VA_ARGS__) | ||||
| 
 | ||||
| extern BOOL IsMPDev(DeviceIntPtr dev); | ||||
| static SpritePtr mpsprites;             /* info about the MPX sprites */ | ||||
| 
 | ||||
| /** 
 | ||||
|  * True for the core pointer and any MPX device.  | ||||
|  | @ -371,7 +371,7 @@ XineramaSetCursorPosition( | |||
|     SpritePtr pSprite = sprite; | ||||
| 
 | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -416,7 +416,7 @@ XineramaConstrainCursor(DeviceIntPtr pDev) | |||
|     BoxRec newBox; | ||||
| 
 | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -445,7 +445,7 @@ XineramaCheckPhysLimits( | |||
|     if (!cursor) | ||||
| 	return; | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
|   | ||||
|  | @ -583,7 +583,7 @@ XineramaCheckMotion(xEvent *xE, DeviceIntPtr pDev) | |||
|     SpritePtr pSprite = sprite; | ||||
| 
 | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -704,7 +704,7 @@ XineramaChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor) | |||
|     SpritePtr pSprite = sprite; | ||||
| 
 | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -748,7 +748,7 @@ ConfineToShape(DeviceIntPtr pDev, RegionPtr shape, int *px, int *py) | |||
|     int incx = 1, incy = 1; | ||||
|     SpritePtr pSprite = sprite; | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -794,7 +794,7 @@ CheckPhysLimits( | |||
|     SpritePtr pSprite = sprite; | ||||
| 
 | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -924,7 +924,7 @@ PointerConfinedToScreen(DeviceIntPtr pDev) | |||
| { | ||||
|     SpritePtr pSprite = sprite; | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
|     return pSprite->confined; | ||||
|  | @ -936,7 +936,7 @@ ChangeToCursor(DeviceIntPtr pDev, CursorPtr cursor) | |||
|     SpritePtr pSprite = sprite; | ||||
| 
 | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -979,7 +979,7 @@ PostNewCursor(DeviceIntPtr pDev) | |||
|     SpritePtr   pSprite = sprite; | ||||
| 
 | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -1018,7 +1018,7 @@ _X_EXPORT WindowPtr | |||
| GetSpriteWindow(DeviceIntPtr pDev) | ||||
| { | ||||
| #ifdef MPX | ||||
|     if(IsMPDev(pDev)) | ||||
|     if(MPHasCursor(pDev)) | ||||
|         return mpsprites[pDev->id].win; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -1036,7 +1036,7 @@ GetSpritePosition(DeviceIntPtr pDev, int *px, int *py) | |||
| { | ||||
|     SpritePtr pSprite = sprite; | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
|     *px = pSprite->hotPhys.x; | ||||
|  | @ -1860,7 +1860,7 @@ FixUpEventFromWindow( | |||
| { | ||||
|     SpritePtr pSprite = sprite; | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -2094,7 +2094,7 @@ CheckMotion(xEvent *xE, DeviceIntPtr pDev) | |||
|     SpritePtr pSprite = sprite; | ||||
|          | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
|          | ||||
|  | @ -2131,7 +2131,7 @@ CheckMotion(xEvent *xE, DeviceIntPtr pDev) | |||
|         xeviehot.y = pSprite->hot.y; | ||||
| #endif | ||||
| 	pSprite->hotPhys = pSprite->hot; | ||||
| #ifndef MPX /* XXX ndef!! */ | ||||
| #if !defined MPX | ||||
| 	if ((pSprite->hotPhys.x != XE_KBPTR.rootX) || | ||||
| 	    (pSprite->hotPhys.y != XE_KBPTR.rootY)) | ||||
| 	{ | ||||
|  | @ -2177,7 +2177,7 @@ WindowsRestructured() | |||
|     DeviceIntPtr pDev = inputInfo.devices; | ||||
|     while(pDev) | ||||
|     { | ||||
|         if (pDev != inputInfo.keyboard) | ||||
|         if (MPHasCursor(pDev)) | ||||
|             CheckMotion((xEvent *)NULL, pDev); | ||||
|         pDev = pDev->next; | ||||
|     } | ||||
|  | @ -2318,7 +2318,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y) | |||
| { | ||||
|     SpritePtr pSprite = sprite; | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(pDev)) | ||||
|     if (MPHasCursor(pDev)) | ||||
|         pSprite = &mpsprites[pDev->id]; | ||||
| #endif | ||||
| 
 | ||||
|  | @ -3051,7 +3051,7 @@ ProcessPointerEvent (register xEvent *xE, register DeviceIntPtr mouse, int count | |||
|     SpritePtr           pSprite = sprite; | ||||
| 
 | ||||
| #ifdef MPX | ||||
|     if (IsMPDev(mouse)) | ||||
|     if (MPHasCursor(mouse)) | ||||
|         pSprite = &mpsprites[mouse->id]; | ||||
| #endif | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) | ||||
|         { | ||||
|             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; | ||||
|      | ||||
|  |  | |||
|  | @ -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,  | ||||
|  |  | |||
							
								
								
									
										100
									
								
								mi/misprite.c
								
								
								
								
							
							
						
						
									
										100
									
								
								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,23 +237,54 @@ 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; | ||||
|  | @ -274,39 +303,6 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) | |||
| 
 | ||||
|     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; | ||||
| 
 | ||||
|     return TRUE; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue