diff options
author | Jamey Sharp <jamey@minilop.net> | 2010-09-17 02:11:44 +0200 |
---|---|---|
committer | Jamey Sharp <jamey@minilop.net> | 2010-09-18 11:17:18 +0200 |
commit | 402942cdbc518395a2943fd226b9f3071f24d39f (patch) | |
tree | 3243b0d059eb9664f45cb3b59c44207f08a00239 /dix | |
parent | e4d4d6ddd52801cf0b0b253d9ba3bdabfa9a9d8d (diff) |
Introduce per-object per-screen privates.
This replaces dixCreatePrivateKey and the only uses, which were in
midispcur.
Commit by Jamey Sharp and Josh Triplett.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'dix')
-rw-r--r-- | dix/privates.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/dix/privates.c b/dix/privates.c index 17e1050d9..687fa7aa0 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -237,28 +237,35 @@ dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size) return TRUE; } -/* - * Allocate a new private key. - * - * This manages the storage of the key object itself, freeing it when the - * privates system is restarted at server reset time. All other keys - * are expected to be statically allocated as the privates must be - * reset after all objects have been freed - */ -DevPrivateKey -dixCreatePrivateKey(DevPrivateType type, unsigned size) +Bool +dixRegisterScreenPrivateKey(DevScreenPrivateKey screenKey, ScreenPtr pScreen, DevPrivateType type, unsigned size) { DevPrivateKey key; + if (!dixRegisterPrivateKey(&screenKey->screenKey, PRIVATE_SCREEN, 0)) + return FALSE; + key = dixGetPrivate(&pScreen->devPrivates, &screenKey->screenKey); + if (key != NULL) { + assert(key->size == size); + assert(key->type == type); + return TRUE; + } key = calloc(sizeof (DevPrivateKeyRec), 1); if (!key) - return NULL; + return FALSE; if (!dixRegisterPrivateKey(key, type, size)) { free(key); - return NULL; + return FALSE; } key->allocated = TRUE; - return key; + dixSetPrivate(&pScreen->devPrivates, &screenKey->screenKey, key); + return TRUE; +} + +DevPrivateKey +_dixGetScreenPrivateKey(const DevScreenPrivateKey key, ScreenPtr pScreen) +{ + return dixGetPrivate(&pScreen->devPrivates, &key->screenKey); } /* |