From b04d64854712678701d5243aacf5cc93444cfadc Mon Sep 17 00:00:00 2001 From: Eamon Walsh Date: Mon, 31 Jul 2006 19:35:08 -0400 Subject: Added devPrivates support to the ExtensionEntry structure. --- dix/extension.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'dix/extension.c') 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; -- cgit v1.2.3