summaryrefslogtreecommitdiff
path: root/dix/privates.c
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@moss-uranus.epoch.ncsc.mil>2006-07-31 19:35:08 -0400
committerEamon Walsh <ewalsh@moss-uranus.epoch.ncsc.mil>2006-07-31 19:35:08 -0400
commitb04d64854712678701d5243aacf5cc93444cfadc (patch)
treeb8a453d1842923dd3253f23dd3157e5c96a3b249 /dix/privates.c
parentc0cb8d1fb80540e093da54da3ee2f55bdf139274 (diff)
Added devPrivates support to the ExtensionEntry structure.
Diffstat (limited to 'dix/privates.c')
-rw-r--r--dix/privates.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/dix/privates.c b/dix/privates.c
index 0c94ff54d..f2ceaf8c6 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -45,6 +45,7 @@ from The Open Group.
#include "servermd.h"
#include "site.h"
#include "inputstr.h"
+#include "extnsionst.h"
/*
* See the Wrappers and devPrivates section in "Definition of the
@@ -53,6 +54,63 @@ from The Open Group.
*/
/*
+ * extension private machinery
+ */
+
+static int extensionPrivateCount;
+int extensionPrivateLen;
+unsigned *extensionPrivateSizes;
+unsigned totalExtensionSize;
+
+void
+ResetExtensionPrivates()
+{
+ extensionPrivateCount = 0;
+ extensionPrivateLen = 0;
+ xfree(extensionPrivateSizes);
+ extensionPrivateSizes = (unsigned *)NULL;
+ totalExtensionSize =
+ ((sizeof(ExtensionEntry) + sizeof(long) - 1) / sizeof(long)) * sizeof(long);
+}
+
+_X_EXPORT int
+AllocateExtensionPrivateIndex()
+{
+ return extensionPrivateCount++;
+}
+
+_X_EXPORT Bool
+AllocateExtensionPrivate(int index2, unsigned amount)
+{
+ unsigned oldamount;
+
+ /* Round up sizes for proper alignment */
+ amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
+
+ if (index2 >= extensionPrivateLen)
+ {
+ unsigned *nsizes;
+ nsizes = (unsigned *)xrealloc(extensionPrivateSizes,
+ (index2 + 1) * sizeof(unsigned));
+ if (!nsizes)
+ return FALSE;
+ while (extensionPrivateLen <= index2)
+ {
+ nsizes[extensionPrivateLen++] = 0;
+ totalExtensionSize += sizeof(DevUnion);
+ }
+ extensionPrivateSizes = nsizes;
+ }
+ oldamount = extensionPrivateSizes[index2];
+ if (amount > oldamount)
+ {
+ extensionPrivateSizes[index2] = amount;
+ totalExtensionSize += (amount - oldamount);
+ }
+ return TRUE;
+}
+
+/*
* client private machinery
*/