summaryrefslogtreecommitdiff
path: root/dix/extension.c
diff options
context:
space:
mode:
Diffstat (limited to 'dix/extension.c')
-rw-r--r--dix/extension.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/dix/extension.c b/dix/extension.c
index bb20ade96..40e1373b6 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -78,6 +78,40 @@ int lastEvent = EXTENSION_EVENT_BASE;
static int lastError = FirstExtensionError;
static unsigned int NumExtensions = 0;
+extern int extensionPrivateLen;
+extern unsigned *extensionPrivateSizes;
+extern unsigned totalExtensionSize;
+
+static int
+InitExtensionPrivates(ExtensionEntry *ext)
+{
+ register char *ptr;
+ DevUnion *ppriv;
+ register unsigned *sizes;
+ register unsigned size;
+ register int i;
+
+ if (totalExtensionSize == sizeof(ExtensionEntry))
+ ppriv = (DevUnion *)NULL;
+ else
+ ppriv = (DevUnion *)(ext + 1);
+
+ ext->devPrivates = ppriv;
+ sizes = extensionPrivateSizes;
+ ptr = (char *)(ppriv + extensionPrivateLen);
+ for (i = extensionPrivateLen; --i >= 0; ppriv++, sizes++)
+ {
+ if ( (size = *sizes) )
+ {
+ ppriv->ptr = (pointer)ptr;
+ ptr += size;
+ }
+ else
+ ppriv->ptr = (pointer)NULL;
+ }
+ return 1;
+}
+
_X_EXPORT ExtensionEntry *
AddExtension(char *name, int NumEvents, int NumErrors,
int (*MainProc)(ClientPtr c1),
@@ -94,8 +128,8 @@ AddExtension(char *name, int NumEvents, int NumErrors,
(unsigned)(lastError + NumErrors > LAST_ERROR))
return((ExtensionEntry *) NULL);
- ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry));
- if (!ext)
+ ext = (ExtensionEntry *) xalloc(totalExtensionSize);
+ if (!ext || !InitExtensionPrivates(ext))
return((ExtensionEntry *) NULL);
ext->name = (char *)xalloc(strlen(name) + 1);
ext->num_aliases = 0;