diff options
author | Eamon Walsh <ewalsh@moss-uranus.epoch.ncsc.mil> | 2006-07-31 19:35:08 -0400 |
---|---|---|
committer | Eamon Walsh <ewalsh@moss-uranus.epoch.ncsc.mil> | 2006-07-31 19:35:08 -0400 |
commit | b04d64854712678701d5243aacf5cc93444cfadc (patch) | |
tree | b8a453d1842923dd3253f23dd3157e5c96a3b249 /dix/extension.c | |
parent | c0cb8d1fb80540e093da54da3ee2f55bdf139274 (diff) |
Added devPrivates support to the ExtensionEntry structure.
Diffstat (limited to 'dix/extension.c')
-rw-r--r-- | dix/extension.c | 38 |
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; |