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:
Keith Packard 2013-07-11 16:08:41 -07:00
parent d25c217964
commit 26f013ba45
2 changed files with 17 additions and 0 deletions

View File

@ -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)
{ {

View File

@ -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)
{ {