diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-13 19:48:28 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-13 19:48:28 +0930 |
commit | cb48d880856fd196ab8e8de5eb1f14944a1b4fff (patch) | |
tree | 4a60003cae628f11189c7bd514a454064ee4547f /dix/devices.c | |
parent | fde3c836628b6cdec3e5d107d6b1b99bc8b86912 (diff) |
Xi: store unused classes in devPrivates.
Rather than freeing/allocing classes each time the device capabilities need to
swap, store them in the devPrivates system.
When a class is unused, it is pushed into the devPrivates, and later recovered
when needed again. This saves us a lot of memory allocations/frees, admittedly
on the cost of some memory.
Diffstat (limited to 'dix/devices.c')
-rw-r--r-- | dix/devices.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/dix/devices.c b/dix/devices.c index a78a1255d..266a66c61 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -89,6 +89,8 @@ SOFTWARE. /* The client that is allowed to change pointer-keyboard pairings. */ static ClientPtr pairingClient = NULL; DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKey; +/* Used to sture classes currently not in use by an MD */ +DevPrivateKey UnusedClassesPrivateKey = &UnusedClassesPrivateKey; /** * Create a new input device and init it to sane values. The device is added @@ -2550,6 +2552,7 @@ AllocMasterDevice(ClientPtr client, char* name, DeviceIntPtr* ptr, DeviceIntPtr* { DeviceIntPtr pointer; DeviceIntPtr keyboard; + ClassesPtr classes; *ptr = *keybd = NULL; pointer = AddInputDevice(client, CorePointerProc, TRUE); @@ -2602,6 +2605,13 @@ AllocMasterDevice(ClientPtr client, char* name, DeviceIntPtr* ptr, DeviceIntPtr* keyboard->u.lastSlave = NULL; keyboard->isMaster = TRUE; + + /* The ClassesRec stores the device classes currently not used. */ + classes = xcalloc(1, sizeof(ClassesRec)); + dixSetPrivate(&pointer->devPrivates, UnusedClassesPrivateKey, classes); + classes = xcalloc(1, sizeof(ClassesRec)); + dixSetPrivate(&keyboard->devPrivates, UnusedClassesPrivateKey, classes); + *ptr = pointer; *keybd = keyboard; |