[PATCH 02/10] Add a RegionDuplicate function

Keith Packard keithp at keithp.com
Thu Oct 31 23:43:34 CET 2013


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 at keithp.com>
---
 dix/region.c        | 15 +++++++++++++++
 include/regionstr.h |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/dix/region.c b/dix/region.c
index 737d2a8..15f3d01 100644
--- a/dix/region.c
+++ b/dix/region.c
@@ -255,6 +255,21 @@ RegionDestroy(RegionPtr 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
 RegionPrint(RegionPtr rgn)
 {
diff --git a/include/regionstr.h b/include/regionstr.h
index 805257b..4a0725d 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -213,6 +213,8 @@ extern _X_EXPORT RegionPtr RegionCreate(BoxPtr /*rect */ ,
 
 extern _X_EXPORT void RegionDestroy(RegionPtr /*pReg */ );
 
+extern _X_EXPORT RegionPtr RegionDuplicate(RegionPtr /* pOld */);
+
 static inline Bool
 RegionCopy(RegionPtr dst, RegionPtr src)
 {
-- 
1.8.4.rc3



More information about the xorg-devel mailing list