Add a RegionDuplicate function
This allocates a new region structure and copies a source region into it in a single API rather than forcing the caller to do both steps themselves. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
		
							parent
							
								
									d25c217964
								
							
						
					
					
						commit
						26f013ba45
					
				
							
								
								
									
										15
									
								
								dix/region.c
								
								
								
								
							
							
						
						
									
										15
									
								
								dix/region.c
								
								
								
								
							|  | @ -255,6 +255,21 @@ RegionDestroy(RegionPtr pReg) | ||||||
|         free(pReg); |         free(pReg); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | RegionPtr | ||||||
|  | RegionDuplicate(RegionPtr pOld) | ||||||
|  | { | ||||||
|  |     RegionPtr   pNew; | ||||||
|  | 
 | ||||||
|  |     pNew = RegionCreate(&pOld->extents, 0); | ||||||
|  |     if (!pNew) | ||||||
|  |         return NULL; | ||||||
|  |     if (!RegionCopy(pNew, pOld)) { | ||||||
|  |         RegionDestroy(pNew); | ||||||
|  |         return NULL; | ||||||
|  |     } | ||||||
|  |     return pNew; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void | void | ||||||
| RegionPrint(RegionPtr rgn) | RegionPrint(RegionPtr rgn) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -213,6 +213,8 @@ extern _X_EXPORT RegionPtr RegionCreate(BoxPtr /*rect */ , | ||||||
| 
 | 
 | ||||||
| extern _X_EXPORT void RegionDestroy(RegionPtr /*pReg */ ); | extern _X_EXPORT void RegionDestroy(RegionPtr /*pReg */ ); | ||||||
| 
 | 
 | ||||||
|  | extern _X_EXPORT RegionPtr RegionDuplicate(RegionPtr /* pOld */); | ||||||
|  | 
 | ||||||
| static inline Bool | static inline Bool | ||||||
| RegionCopy(RegionPtr dst, RegionPtr src) | RegionCopy(RegionPtr dst, RegionPtr src) | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue