debian/changelog                    |   29 ++++++++++++++++++++++++--
 dix/getevents.c                     |    6 ++---
 glx/Makefile.am                     |    6 ++++-
 hw/xfree86/dixmods/extmod/xf86dga.c |    7 ++++--
 hw/xfree86/int10/helper_exec.c      |   15 +------------
 hw/xfree86/modes/xf86Crtc.c         |    3 +-
 mfb/mfbscrinit.c                    |    1 
 xkb/XKBMisc.c                       |   13 +++++++++---
 xkb/xkb.c                           |   17 ++++-----------
 xkb/xkbUtils.c                      |   39 +++++++++++++++++++++++++++++++-----
 10 files changed, 92 insertions(+), 44 deletions(-)

New commits:
commit 45864afe321c3547f8471ee36c48c3ca1b6dffe3
Author: Timo Aaltonen <[EMAIL PROTECTED]>
Date:   Tue Oct 14 23:37:01 2008 +0300

    Prepare the changelog for upload

diff --git a/debian/changelog b/debian/changelog
index 3915b3f..0928ea2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-xorg-server (2:1.5.1-1ubuntu3) UNRELEASED; urgency=low
+xorg-server (2:1.5.1-1ubuntu3) intrepid; urgency=low
 
   * Pull upstream changes from server-1.5-branch including b595b65e:
     - Fix GKVE with key_code > 255 (LP: #274203) 
@@ -31,7 +31,7 @@ xorg-server (2:1.5.1-1ubuntu3) UNRELEASED; urgency=low
   * Add Breaks against current synaptics and evdev, since they use the old
     API and need to be updated with the server.
 
- -- Timo Aaltonen <[EMAIL PROTECTED]>  Fri, 10 Oct 2008 11:00:21 +0300
+ -- Timo Aaltonen <[EMAIL PROTECTED]>  Fri, 10 Oct 2008 11:16:56 +0300
 
 xorg-server (2:1.5.1-1ubuntu2) intrepid; urgency=low
 

commit 70077e8042e2efc4acdc49da6b1aa06a851c43bf
Author: Timo Aaltonen <[EMAIL PROTECTED]>
Date:   Fri Oct 10 11:07:46 2008 +0300

    Update the changelog.

diff --git a/debian/changelog b/debian/changelog
index 89ee923..3915b3f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,28 @@
 xorg-server (2:1.5.1-1ubuntu3) UNRELEASED; urgency=low
 
+  * Pull upstream changes from server-1.5-branch including b595b65e:
+    - Fix GKVE with key_code > 255 (LP: #274203) 
+    - DGA: Fix ProcXF86DGASetViewPort for missing support in driver.
+      Fixes a segfault when trying to activate a DGA mode without
+      checking whether DGA modesetting is at all possible.
+    - Check nextEnabledOutput()'s return in bestModeForAspect()
+      In case no enabled outputs, we will reference wrong index of
+      output array.
+    - int10: Fix a nasty memory leak.
+    - int10: Don't warn when scanning for devices we don't have.
+      Some BIOSes (hi XGI!) will attempt to enumerate the PCI bus by
+      asking for the config space of every possible device number.
+      This despite perfectly functional BIOS methods to enumerate the
+      bus exactly.
+    - int10: Remove useless check.
+      If you have more than one PCI device with the same d/b/d/f, you're
+      already in trouble.
+    - http://bugs.freedesktop.org/show_bug.cgi?id=14373
+      xkb: squash canonical types into explicit ones on core reconstruction.
+      xkb: fix core keyboard map generation.
+    - xkb: fix use of uninitialized variable.
+    - Remove usage of mfbChangeWindowAttributes missed in e4d11e58c...
+    - Only build dri2 when DRI2 is enabled.
   * Merge patches 138 and 139 into 137, and update the properties API to
     match the current version in master (final API for XI 1.5).
     (LP: #274728)
@@ -8,7 +31,7 @@ xorg-server (2:1.5.1-1ubuntu3) UNRELEASED; urgency=low
   * Add Breaks against current synaptics and evdev, since they use the old
     API and need to be updated with the server.
 
- -- Timo Aaltonen <[EMAIL PROTECTED]>  Thu, 09 Oct 2008 14:18:23 +0300
+ -- Timo Aaltonen <[EMAIL PROTECTED]>  Fri, 10 Oct 2008 11:00:21 +0300
 
 xorg-server (2:1.5.1-1ubuntu2) intrepid; urgency=low
 

commit b595b65e54b1e15fbce872fe3719da14cfae5b92
Author: Adam Jackson <[EMAIL PROTECTED]>
Date:   Thu Oct 9 14:53:29 2008 -0400

    Revert "Array-index based devPrivates implementation."
    
    This reverts commit 8ef37c194fa08d3911095299413a42a01162b078.

diff --git a/dix/privates.c b/dix/privates.c
index ca03317..efb3204 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -40,8 +40,9 @@ from The Open Group.
 #include "inputstr.h"
 
 struct _Private {
-    int state;
-    pointer value;
+    DevPrivateKey      key;
+    pointer            value;
+    struct _Private    *next;
 };
 
 typedef struct _PrivateDesc {
@@ -49,36 +50,22 @@ typedef struct _PrivateDesc {
     unsigned size;
     CallbackListPtr initfuncs;
     CallbackListPtr deletefuncs;
+    struct _PrivateDesc *next;
 } PrivateDescRec;
 
-#define PRIV_MAX 256
-#define PRIV_STEP 16
-
 /* list of all allocated privates */
-static PrivateDescRec items[PRIV_MAX];
-static int nextPriv;
+static PrivateDescRec *items = NULL;
 
-static PrivateDescRec *
+static _X_INLINE PrivateDescRec *
 findItem(const DevPrivateKey key)
 {
-    if (!*key) {
-       if (nextPriv >= PRIV_MAX)
-           return NULL;
-
-       items[nextPriv].key = key;
-       *key = nextPriv;
-       nextPriv++;
+    PrivateDescRec *item = items;
+    while (item) {
+       if (item->key == key)
+           return item;
+       item = item->next;
     }
-
-    return items + *key;
-}
-
-static _X_INLINE int
-privateExists(PrivateRec **privates, const DevPrivateKey key)
-{
-    return *key && *privates &&
-       (*privates)[0].state > *key &&
-       (*privates)[*key].state;
+    return NULL;
 }
 
 /*
@@ -88,10 +75,21 @@ _X_EXPORT int
 dixRequestPrivate(const DevPrivateKey key, unsigned size)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item)
-       return FALSE;
-    if (size > item->size)
+    if (item) {
+       if (size > item->size)
+           item->size = size;
+    } else {
+       item = (PrivateDescRec *)xalloc(sizeof(PrivateDescRec));
+       if (!item)
+           return FALSE;
+       memset(item, 0, sizeof(PrivateDescRec));
+
+       /* add privates descriptor */
+       item->key = key;
        item->size = size;
+       item->next = items;
+       items = item;
+    }
     return TRUE;
 }
 
@@ -102,52 +100,25 @@ _X_EXPORT pointer *
 dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
 {
     PrivateDescRec *item = findItem(key);
-    PrivateCallbackRec calldata;
     PrivateRec *ptr;
-    pointer value;
-    int oldsize, newsize;
-
-    newsize = (*key / PRIV_STEP + 1) * PRIV_STEP;
+    unsigned size = sizeof(PrivateRec);
+    
+    if (item)
+       size += item->size;
 
-    /* resize or init privates array */
-    if (!item)
+    ptr = (PrivateRec *)xcalloc(size, 1);
+    if (!ptr)
        return NULL;
-
-    /* initialize privates array if necessary */
-    if (!*privates) {
-       ptr = xcalloc(newsize, sizeof(*ptr));
-       if (!ptr)
-           return NULL;
-       *privates = ptr;
-       (*privates)[0].state = newsize;
-    }
-
-    oldsize = (*privates)[0].state;
-
-    /* resize privates array if necessary */
-    if (*key >= oldsize) {
-       ptr = xrealloc(*privates, newsize * sizeof(*ptr));
-       if (!ptr)
-           return NULL;
-       memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr));
-       *privates = ptr;
-       (*privates)[0].state = newsize;
-    }
-
-    /* initialize slot */
-    ptr = *privates + *key;
-    ptr->state = 1;
-    if (item->size) {
-       value = xcalloc(item->size, 1);
-       if (!value)
-           return NULL;
-       ptr->value = value;
+    ptr->key = key;
+    ptr->value = (size > sizeof(PrivateRec)) ? (ptr + 1) : NULL;
+    ptr->next = *privates;
+    *privates = ptr;
+
+    /* call any init funcs and return */
+    if (item) {
+       PrivateCallbackRec calldata = { key, &ptr->value };
+       CallCallbacks(&item->initfuncs, &calldata);
     }
-
-    calldata.key = key;
-    calldata.value = &ptr->value;
-    CallCallbacks(&item->initfuncs, &calldata);
-
     return &ptr->value;
 }
 
@@ -157,10 +128,14 @@ dixAllocatePrivate(PrivateRec **privates, const 
DevPrivateKey key)
 _X_EXPORT pointer
 dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
 {
+    PrivateRec *rec = *privates;
     pointer *ptr;
 
-    if (privateExists(privates, key))
-       return (*privates)[*key].value;
+    while (rec) {
+       if (rec->key == key)
+           return rec->value;
+       rec = rec->next;
+    }
 
     ptr = dixAllocatePrivate(privates, key);
     return ptr ? *ptr : NULL;
@@ -172,8 +147,13 @@ dixLookupPrivate(PrivateRec **privates, const 
DevPrivateKey key)
 _X_EXPORT pointer *
 dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
 {
-    if (privateExists(privates, key))
-       return &(*privates)[*key].value;
+    PrivateRec *rec = *privates;
+
+    while (rec) {
+       if (rec->key == key)
+           return &rec->value;
+       rec = rec->next;
+    }
 
     return dixAllocatePrivate(privates, key);
 }
@@ -184,10 +164,16 @@ dixLookupPrivateAddr(PrivateRec **privates, const 
DevPrivateKey key)
 _X_EXPORT int
 dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
 {
+    PrivateRec *rec;
+
  top:
-    if (privateExists(privates, key)) {
-       (*privates)[*key].value = val;
-       return TRUE;
+    rec = *privates;
+    while (rec) {
+       if (rec->key == key) {
+           rec->value = val;
+           return TRUE;
+       }
+       rec = rec->next;
     }
 
     if (!dixAllocatePrivate(privates, key))
@@ -201,23 +187,27 @@ dixSetPrivate(PrivateRec **privates, const DevPrivateKey 
key, pointer val)
 _X_EXPORT void
 dixFreePrivates(PrivateRec *privates)
 {
-    int i;
+    PrivateRec *ptr, *next;
+    PrivateDescRec *item;
     PrivateCallbackRec calldata;
 
-    if (privates)
-       for (i = 1; i < privates->state; i++)
-           if (privates[i].state) {
-               /* call the delete callbacks */
-               calldata.key = items[i].key;
-               calldata.value = &privates[i].value;
-               CallCallbacks(&items[i].deletefuncs, &calldata);
-
-               /* free pre-allocated memory */
-               if (items[i].size)
-                   xfree(privates[i].value);
-           }
-
-    xfree(privates);
+    /* first pass calls the delete callbacks */
+    for (ptr = privates; ptr; ptr = ptr->next) {
+       item = findItem(ptr->key);
+       if (item) {
+           calldata.key = ptr->key;
+           calldata.value = &ptr->value;
+           CallCallbacks(&item->deletefuncs, &calldata);
+       }
+    }
+       
+    /* second pass frees the memory */
+    ptr = privates;
+    while (ptr) {
+       next = ptr->next;
+       xfree(ptr);
+       ptr = next;
+    }
 }
 
 /*
@@ -228,9 +218,11 @@ dixRegisterPrivateInitFunc(const DevPrivateKey key,
                           CallbackProcPtr callback, pointer data)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item)
-       return FALSE;
-
+    if (!item) {
+       if (!dixRequestPrivate(key, 0))
+           return FALSE;
+       item = findItem(key);
+    }
     return AddCallback(&item->initfuncs, callback, data);
 }
 
@@ -239,9 +231,11 @@ dixRegisterPrivateDeleteFunc(const DevPrivateKey key,
                             CallbackProcPtr callback, pointer data)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item)
-       return FALSE;
-
+    if (!item) {
+       if (!dixRequestPrivate(key, 0))
+           return FALSE;
+       item = findItem(key);
+    }
     return AddCallback(&item->deletefuncs, callback, data);
 }
 
@@ -298,17 +292,16 @@ dixLookupPrivateOffset(RESTYPE type)
 int
 dixResetPrivates(void)
 {
-    int i;
-
-    /* reset private descriptors */
-    for (i = 1; i < nextPriv; i++) {
-       *items[i].key = 0;
-       DeleteCallbackList(&items[i].initfuncs);
-       DeleteCallbackList(&items[i].deletefuncs);
+    PrivateDescRec *next;
+
+    /* reset internal structures */
+    while (items) {
+       next = items->next;
+       DeleteCallbackList(&items->initfuncs);
+       DeleteCallbackList(&items->deletefuncs);
+       xfree(items);
+       items = next;
     }
-    nextPriv = 1;
-
-    /* reset offsets */
     if (offsets)
        xfree(offsets);
     offsetsSize = sizeof(offsetDefaults);
diff --git a/include/privates.h b/include/privates.h
index e3fa83c..98d893c 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -19,7 +19,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE SOFTWARE.
  * STUFF FOR PRIVATES
  *****************************************************************/
 
-typedef int *DevPrivateKey;
+typedef void *DevPrivateKey;
 struct _Private;
 typedef struct _Private PrivateRec;
 

commit ca659813a81074cae55ffec51f923c658480b618
Author: Julien Cristau <[EMAIL PROTECTED]>
Date:   Wed Oct 8 19:46:50 2008 +0200

    Fix GKVE with key_code > 255
    
    Move the keycode validation checks before use.

diff --git a/dix/getevents.c b/dix/getevents.c
index fbead11..1e0edbf 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -411,9 +411,6 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr 
pDev, int type,
     KeySym sym;
     deviceKeyButtonPointer *kbp = NULL;
 
-    sym = map[(key_code - pDev->key->curKeySyms.minKeyCode)
-              * pDev->key->curKeySyms.mapWidth];
-
     if (!events)
         return 0;
 
@@ -428,6 +425,9 @@ GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr 
pDev, int type,
     if (key_code < 8 || key_code > 255)
         return 0;
 
+    sym = map[(key_code - pDev->key->curKeySyms.minKeyCode)
+              * pDev->key->curKeySyms.mapWidth];
+
     if (pDev->coreEvents)
         numEvents = 2;
     else

commit 8337c9aa3d2009eea801a84b3a65272e03e65e1a
Author: Luc Verhaegen <[EMAIL PROTECTED]>
Date:   Wed Oct 8 14:55:29 2008 +0200

    DGA: Fix ProcXF86DGASetViewPort for missing support in driver.
    
    Fixes a segfault when trying to activate a DGA mode without checking
    whether DGA modesetting is at all possible.
    (cherry picked from commit 1feb69eb63e6739ff5db255ad529e84adf941a10)

diff --git a/hw/xfree86/dixmods/extmod/xf86dga.c 
b/hw/xfree86/dixmods/extmod/xf86dga.c
index 0736167..c66bca2 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga.c
@@ -93,7 +93,7 @@ ProcXF86DGADirectVideo(ClientPtr client)
 
     REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
 
-    if (!DGAAvailable(stuff->screen)) 
+    if (!DGAAvailable(stuff->screen))
        return DGAErrorBase + XF86DGANoDirectVideoMode;
 
     if (stuff->enable & XF86DGADirectGraphics) {
@@ -128,7 +128,7 @@ ProcXF86DGAGetViewPortSize(ClientPtr client)
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
 
-    if (!DGAAvailable(stuff->screen)) 
+    if (!DGAAvailable(stuff->screen))
        return (DGAErrorBase + XF86DGANoDirectVideoMode);
 
     if(!(num = DGAGetOldDGAMode(stuff->screen)))
@@ -153,6 +153,9 @@ ProcXF86DGASetViewPort(ClientPtr client)
 
     REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
 
+    if (!DGAAvailable(stuff->screen))
+       return (DGAErrorBase + XF86DGANoDirectVideoMode);
+
     if (!DGAActive(stuff->screen))
     {
        int num;

commit 4e6cbd323854709ae00c44108c93ab6596151de2
Author: Zhenyu Wang <[EMAIL PROTECTED]>
Date:   Wed Oct 8 13:33:55 2008 +0800

    Check nextEnabledOutput()'s return in bestModeForAspect()
    
    In case no enabled outputs, we will reference wrong index of
    output array.
    (cherry picked from commit 56c615368c5a8e7acb0398434c2c68578626aa38)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 2080b23..1facf86 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1903,7 +1903,8 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool 
*enabled, float aspect)
     int o = -1, p;
     DisplayModePtr mode = NULL, test = NULL, match = NULL;
 
-    nextEnabledOutput(config, enabled, &o);
+    if (!nextEnabledOutput(config, enabled, &o))
+       return NULL;
     while ((mode = nextAspectMode(config->output[o], mode, aspect))) {
        test = mode;
        for (p = o; nextEnabledOutput(config, enabled, &p); ) {

commit 43e3af9cac2e9fd613a61a870bfe00f4782a368d
Author: Adam Jackson <[EMAIL PROTECTED]>
Date:   Tue Oct 7 13:41:25 2008 -0400

    int10: Fix a nasty memory leak.
    (cherry picked from commit 94919480d8bb66e1807b4fe87b8f326ef6e012c6)

diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index 4e5f6d3..15eba49 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -482,6 +482,8 @@ pci_device_for_cfg_address (CARD32 addr)
        if (iter)
                dev = pci_device_next(iter);
 
+       pci_iterator_destroy(iter);
+
        return dev;
 }
 

commit 00ac80a0c408106158bf258b6da8350611fbfe84
Author: Adam Jackson <[EMAIL PROTECTED]>
Date:   Tue Oct 7 13:39:10 2008 -0400

    int10: Don't warn when scanning for devices we don't have.
    
    Some BIOSes (hi XGI!) will attempt to enumerate the PCI bus by asking
    for the config space of every possible device number.  This despite
    perfectly functional BIOS methods to enumerate the bus exactly.
    (cherry picked from commit a57b2f172c1291f22f7ba2780c1b2f55e353c3e9)

diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index ff8143f..4e5f6d3 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -478,15 +478,9 @@ pci_device_for_cfg_address (CARD32 addr)
 
        struct pci_device_iterator *iter =
            pci_slot_match_iterator_create (&slot_match);
+
        if (iter)
                dev = pci_device_next(iter);
-       if (!dev) {
-               char buf[128]; /* enough to store "[EMAIL PROTECTED]" */
-               xf86FormatPciBusNumber(tag >> 16, buf);
-               ErrorF("Failed to find device matching %s:%u:%u\n",
-                               buf, slot_match.dev, slot_match.func);
-               return NULL;
-       }
 
        return dev;
 }

commit c6ce2f6b3fe12e65b0e8a75cc1bc0a21875e14e3
Author: Adam Jackson <[EMAIL PROTECTED]>
Date:   Tue Oct 7 13:38:12 2008 -0400

    int10: Remove useless check.
    
    If you have more than one PCI device with the same d/b/d/f, you're
    already in trouble.
    (cherry picked from commit a65e36a873cd1ba9896cd0f9a3e94dd933666005)

diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index c3af5bc..ff8143f 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -488,13 +488,6 @@ pci_device_for_cfg_address (CARD32 addr)
                return NULL;
        }
 
-       if (pci_device_next(iter)) {
-               char buf[128]; /* enough to store "[EMAIL PROTECTED]" */
-               xf86FormatPciBusNumber(tag >> 16, buf);
-               ErrorF("Multiple devices matching %s:%u:%u\n",
-                               buf, slot_match.dev, slot_match.func);
-       }
-
        return dev;
 }
 

commit 8ef37c194fa08d3911095299413a42a01162b078
Author: Eamon Walsh <[EMAIL PROTECTED]>
Date:   Fri Sep 12 19:11:53 2008 -0400

    Array-index based devPrivates implementation.
    
    Note: DevPrivateKey is now pointer-to-int, which means
    each key now needs to point to some global storage of
    size at least sizeof(int).
    
    (cherry picked from commit b6ab114212c0e4c3346ceb5b207f14c526ab81e7)

diff --git a/dix/privates.c b/dix/privates.c
index efb3204..ca03317 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -40,9 +40,8 @@ from The Open Group.
 #include "inputstr.h"
 
 struct _Private {
-    DevPrivateKey      key;
-    pointer            value;
-    struct _Private    *next;
+    int state;
+    pointer value;
 };
 
 typedef struct _PrivateDesc {
@@ -50,22 +49,36 @@ typedef struct _PrivateDesc {
     unsigned size;
     CallbackListPtr initfuncs;
     CallbackListPtr deletefuncs;
-    struct _PrivateDesc *next;
 } PrivateDescRec;
 
+#define PRIV_MAX 256
+#define PRIV_STEP 16
+
 /* list of all allocated privates */
-static PrivateDescRec *items = NULL;
+static PrivateDescRec items[PRIV_MAX];
+static int nextPriv;
 
-static _X_INLINE PrivateDescRec *
+static PrivateDescRec *
 findItem(const DevPrivateKey key)
 {
-    PrivateDescRec *item = items;
-    while (item) {
-       if (item->key == key)
-           return item;
-       item = item->next;
+    if (!*key) {
+       if (nextPriv >= PRIV_MAX)
+           return NULL;
+
+       items[nextPriv].key = key;
+       *key = nextPriv;
+       nextPriv++;
     }
-    return NULL;
+
+    return items + *key;
+}
+
+static _X_INLINE int
+privateExists(PrivateRec **privates, const DevPrivateKey key)
+{
+    return *key && *privates &&
+       (*privates)[0].state > *key &&
+       (*privates)[*key].state;
 }
 
 /*
@@ -75,21 +88,10 @@ _X_EXPORT int
 dixRequestPrivate(const DevPrivateKey key, unsigned size)
 {
     PrivateDescRec *item = findItem(key);
-    if (item) {
-       if (size > item->size)
-           item->size = size;
-    } else {
-       item = (PrivateDescRec *)xalloc(sizeof(PrivateDescRec));
-       if (!item)
-           return FALSE;
-       memset(item, 0, sizeof(PrivateDescRec));
-
-       /* add privates descriptor */
-       item->key = key;
+    if (!item)
+       return FALSE;
+    if (size > item->size)
        item->size = size;
-       item->next = items;
-       items = item;
-    }
     return TRUE;
 }
 
@@ -100,25 +102,52 @@ _X_EXPORT pointer *
 dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
 {
     PrivateDescRec *item = findItem(key);
+    PrivateCallbackRec calldata;
     PrivateRec *ptr;
-    unsigned size = sizeof(PrivateRec);
-    
-    if (item)
-       size += item->size;
+    pointer value;
+    int oldsize, newsize;
+
+    newsize = (*key / PRIV_STEP + 1) * PRIV_STEP;
 
-    ptr = (PrivateRec *)xcalloc(size, 1);
-    if (!ptr)
+    /* resize or init privates array */
+    if (!item)
        return NULL;
-    ptr->key = key;
-    ptr->value = (size > sizeof(PrivateRec)) ? (ptr + 1) : NULL;
-    ptr->next = *privates;
-    *privates = ptr;
-
-    /* call any init funcs and return */
-    if (item) {
-       PrivateCallbackRec calldata = { key, &ptr->value };
-       CallCallbacks(&item->initfuncs, &calldata);
+
+    /* initialize privates array if necessary */
+    if (!*privates) {
+       ptr = xcalloc(newsize, sizeof(*ptr));
+       if (!ptr)
+           return NULL;
+       *privates = ptr;
+       (*privates)[0].state = newsize;
+    }
+
+    oldsize = (*privates)[0].state;
+
+    /* resize privates array if necessary */
+    if (*key >= oldsize) {
+       ptr = xrealloc(*privates, newsize * sizeof(*ptr));
+       if (!ptr)
+           return NULL;
+       memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr));
+       *privates = ptr;
+       (*privates)[0].state = newsize;
+    }
+
+    /* initialize slot */
+    ptr = *privates + *key;
+    ptr->state = 1;
+    if (item->size) {
+       value = xcalloc(item->size, 1);
+       if (!value)
+           return NULL;
+       ptr->value = value;
     }
+
+    calldata.key = key;
+    calldata.value = &ptr->value;
+    CallCallbacks(&item->initfuncs, &calldata);
+
     return &ptr->value;
 }
 
@@ -128,14 +157,10 @@ dixAllocatePrivate(PrivateRec **privates, const 
DevPrivateKey key)
 _X_EXPORT pointer
 dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
 {
-    PrivateRec *rec = *privates;
     pointer *ptr;
 
-    while (rec) {
-       if (rec->key == key)
-           return rec->value;
-       rec = rec->next;
-    }
+    if (privateExists(privates, key))
+       return (*privates)[*key].value;
 
     ptr = dixAllocatePrivate(privates, key);
     return ptr ? *ptr : NULL;
@@ -147,13 +172,8 @@ dixLookupPrivate(PrivateRec **privates, const 
DevPrivateKey key)
 _X_EXPORT pointer *
 dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
 {
-    PrivateRec *rec = *privates;
-
-    while (rec) {
-       if (rec->key == key)
-           return &rec->value;
-       rec = rec->next;
-    }
+    if (privateExists(privates, key))
+       return &(*privates)[*key].value;
 
     return dixAllocatePrivate(privates, key);
 }
@@ -164,16 +184,10 @@ dixLookupPrivateAddr(PrivateRec **privates, const 
DevPrivateKey key)
 _X_EXPORT int
 dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
 {
-    PrivateRec *rec;
-
  top:
-    rec = *privates;
-    while (rec) {
-       if (rec->key == key) {
-           rec->value = val;
-           return TRUE;
-       }
-       rec = rec->next;
+    if (privateExists(privates, key)) {
+       (*privates)[*key].value = val;
+       return TRUE;
     }
 
     if (!dixAllocatePrivate(privates, key))
@@ -187,27 +201,23 @@ dixSetPrivate(PrivateRec **privates, const DevPrivateKey 
key, pointer val)
 _X_EXPORT void
 dixFreePrivates(PrivateRec *privates)
 {
-    PrivateRec *ptr, *next;
-    PrivateDescRec *item;
+    int i;
     PrivateCallbackRec calldata;
 
-    /* first pass calls the delete callbacks */
-    for (ptr = privates; ptr; ptr = ptr->next) {
-       item = findItem(ptr->key);
-       if (item) {
-           calldata.key = ptr->key;
-           calldata.value = &ptr->value;
-           CallCallbacks(&item->deletefuncs, &calldata);
-       }
-    }
-       
-    /* second pass frees the memory */
-    ptr = privates;
-    while (ptr) {
-       next = ptr->next;
-       xfree(ptr);
-       ptr = next;
-    }
+    if (privates)
+       for (i = 1; i < privates->state; i++)
+           if (privates[i].state) {
+               /* call the delete callbacks */
+               calldata.key = items[i].key;
+               calldata.value = &privates[i].value;
+               CallCallbacks(&items[i].deletefuncs, &calldata);
+
+               /* free pre-allocated memory */
+               if (items[i].size)
+                   xfree(privates[i].value);
+           }
+
+    xfree(privates);
 }
 
 /*
@@ -218,11 +228,9 @@ dixRegisterPrivateInitFunc(const DevPrivateKey key,
                           CallbackProcPtr callback, pointer data)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item) {
-       if (!dixRequestPrivate(key, 0))
-           return FALSE;
-       item = findItem(key);
-    }
+    if (!item)
+       return FALSE;
+
     return AddCallback(&item->initfuncs, callback, data);
 }
 
@@ -231,11 +239,9 @@ dixRegisterPrivateDeleteFunc(const DevPrivateKey key,
                             CallbackProcPtr callback, pointer data)
 {
     PrivateDescRec *item = findItem(key);
-    if (!item) {
-       if (!dixRequestPrivate(key, 0))
-           return FALSE;
-       item = findItem(key);
-    }
+    if (!item)
+       return FALSE;
+
     return AddCallback(&item->deletefuncs, callback, data);
 }
 
@@ -292,16 +298,17 @@ dixLookupPrivateOffset(RESTYPE type)
 int
 dixResetPrivates(void)
 {
-    PrivateDescRec *next;
-
-    /* reset internal structures */
-    while (items) {
-       next = items->next;
-       DeleteCallbackList(&items->initfuncs);
-       DeleteCallbackList(&items->deletefuncs);
-       xfree(items);
-       items = next;
+    int i;
+
+    /* reset private descriptors */
+    for (i = 1; i < nextPriv; i++) {
+       *items[i].key = 0;
+       DeleteCallbackList(&items[i].initfuncs);
+       DeleteCallbackList(&items[i].deletefuncs);
     }
+    nextPriv = 1;
+
+    /* reset offsets */
     if (offsets)
        xfree(offsets);
     offsetsSize = sizeof(offsetDefaults);
diff --git a/include/privates.h b/include/privates.h
index 98d893c..e3fa83c 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -19,7 +19,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE SOFTWARE.
  * STUFF FOR PRIVATES
  *****************************************************************/
 
-typedef void *DevPrivateKey;
+typedef int *DevPrivateKey;
 struct _Private;
 typedef struct _Private PrivateRec;
 

commit e88df87851232d6b6c8da5fff802b33f5275b050
Author: Peter Hutterer <[EMAIL PROTECTED]>
Date:   Mon Sep 22 11:10:46 2008 +0930

    xkb: squash canonical types into explicit ones on core reconstruction.
    
    If we update key types from core, and groups 2 - n have a canonical type but
    the same symbols as the explicit type of group 1, assume that it was a core
    sym duplication according to Section 12.4 of the XKB Protocol Spec.
    Ignore the canonical types and pretend there's only one group for the key -
    with the explicit key type.
    
    The protocol spec does not cover this case, so we have to guess here.
    (cherry picked from commit 30c3c13f1030268aaa6a3598d538fafd0592d77a)

diff --git a/xkb/XKBMisc.c b/xkb/XKBMisc.c
index 85415a4..ac81395 100644
--- a/xkb/XKBMisc.c
+++ b/xkb/XKBMisc.c
@@ -178,16 +178,23 @@ int               nGroups,tmp,groupsWidth;
        }
     }
 
-    /* step 7: check for all groups identical or all width 1 */
+    /* step 7: check for all groups identical or all width 1
+     *
+     * Special feature: if group 1 has an explicit type and all other groups
+     * have canonical types with same symbols, we assume it's info lost from
+     * the core replication.
+     */
     if (nGroups>1) {
-       Bool sameType,allOneLevel;
+       Bool sameType,allOneLevel, canonical = True;
        allOneLevel= (xkb->map->types[types_inout[0]].num_levels==1);
        for (i=1,sameType=True;(allOneLevel||sameType)&&(i<nGroups);i++) {
            sameType=(sameType&&(types_inout[i]==types_inout[XkbGroup1Index]));
            if (allOneLevel)
                allOneLevel= (xkb->map->types[types_inout[i]].num_levels==1);
+           if (types_inout[i] > XkbLastRequiredType)
+               canonical = False;
        }
-       if ((sameType)&&
+       if (((sameType) || canonical)&&
            (!(protected&(XkbExplicitKeyTypesMask&~XkbExplicitKeyType1Mask)))){
            register int s;
            Bool        identical;

commit be3b3cb970d040f0db4bead018c338012547334f
Author: Peter Hutterer <[EMAIL PROTECTED]>
Date:   Fri Sep 19 18:27:24 2008 +0930

    xkb: fix core keyboard map generation. #14373
    
    According to Section 12.4 of the XKB Protocol Spec, if a key only has a 
single
    group but the keyboard has multiple groups defined, the core description of
    the key is a duplication of the single group across all symbols. i.e.
    G1L1 G1L2 G1L1 G1L2 G1L3 G1L4 G1L3 G1L4
    
    The previous code generated G1L1 G1L2 G1L3 G1L4 G1L3 G1L4, leading to
    "invented" groups when the process is reversed.
    
    Note that this creates wrong key types on reconstruction from core to xkb,
    i.e. any single-group key with a key type that is not one of the canonical
    four (Sec 12.2.3), will get the assigned type on group 1, and a canonical 
type


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to