Simplify usage of drmHash functions and fix bug in
__driGarbageCollectDrawables which would get confused while walking the hash values.
This commit is contained in:
@@ -235,34 +235,13 @@ static GLboolean __driAddDrawable(void *drawHash, __DRIdrawable *pdraw)
|
|||||||
static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw)
|
static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw)
|
||||||
{
|
{
|
||||||
int retcode;
|
int retcode;
|
||||||
union
|
|
||||||
{
|
|
||||||
__DRIdrawable *pdraw;
|
__DRIdrawable *pdraw;
|
||||||
void *ptr;
|
|
||||||
} p;
|
|
||||||
|
|
||||||
retcode = drmHashLookup(drawHash, draw, &p.ptr);
|
retcode = drmHashLookup(drawHash, draw, (void *)&pdraw);
|
||||||
if (retcode)
|
if (retcode)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return p.pdraw;
|
return pdraw;
|
||||||
}
|
|
||||||
|
|
||||||
static void __driRemoveDrawable(void *drawHash, __DRIdrawable *pdraw)
|
|
||||||
{
|
|
||||||
int retcode;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
__DRIdrawablePrivate *pdp;
|
|
||||||
void *ptr;
|
|
||||||
} p;
|
|
||||||
|
|
||||||
p.pdp = (__DRIdrawablePrivate *)pdraw->private;
|
|
||||||
|
|
||||||
retcode = drmHashLookup(drawHash, p.pdp->draw, &p.ptr);
|
|
||||||
if (!retcode) { /* Found */
|
|
||||||
drmHashDelete(drawHash, p.pdp->draw);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DRI_NEW_INTERFACE_ONLY
|
#ifndef DRI_NEW_INTERFACE_ONLY
|
||||||
@@ -320,24 +299,20 @@ static void __driGarbageCollectDrawables(void *drawHash)
|
|||||||
{
|
{
|
||||||
__DRIid draw;
|
__DRIid draw;
|
||||||
__DRInativeDisplay *dpy;
|
__DRInativeDisplay *dpy;
|
||||||
union
|
|
||||||
{
|
|
||||||
__DRIdrawable *pdraw;
|
__DRIdrawable *pdraw;
|
||||||
void *ptr;
|
|
||||||
} p;
|
|
||||||
|
|
||||||
if (drmHashFirst(drawHash, &draw, &p.ptr)) {
|
if (drmHashFirst(drawHash, &draw, (void *)&pdraw) == 1) {
|
||||||
do {
|
do {
|
||||||
__DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)p.pdraw->private;
|
__DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
|
||||||
dpy = pdp->driScreenPriv->display;
|
dpy = pdp->driScreenPriv->display;
|
||||||
if (! (*window_exists)(dpy, draw)) {
|
if (! (*window_exists)(dpy, draw)) {
|
||||||
/* Destroy the local drawable data in the hash table, if the
|
/* Destroy the local drawable data in the hash table, if the
|
||||||
drawable no longer exists in the Xserver */
|
drawable no longer exists in the Xserver */
|
||||||
__driRemoveDrawable(drawHash, p.pdraw);
|
drmHashDelete(drawHash, draw);
|
||||||
(*p.pdraw->destroyDrawable)(dpy, p.pdraw->private);
|
(*pdraw->destroyDrawable)(dpy, pdraw->private);
|
||||||
_mesa_free(p.pdraw);
|
_mesa_free(pdraw);
|
||||||
}
|
}
|
||||||
} while (drmHashNext(drawHash, &draw, &p.ptr));
|
} while (drmHashNext(drawHash, &draw, (void *)&pdraw) == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user