This will be shared between dri and dri2 code.
return NULL;
}
+static void driDestroyDrawable(__GLXDRIdrawable *pdraw)
+{
+ __GLXscreenConfigs *psc = pdraw->psc;
+
+ (*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable);
+ XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable);
+ Xfree(pdraw);
+}
static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
GLXDrawable drawable,
return NULL;
}
- if (__glxHashInsert(psc->drawHash, drawable, pdraw)) {
- (*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable);
- XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);
- Xfree(pdraw);
- return NULL;
- }
+ pdraw->destroyDrawable = driDestroyDrawable;
return pdraw;
}
if (psc->__driScreen.private)
(*psc->__driScreen.destroyScreen)(&psc->__driScreen);
psc->__driScreen.private = NULL;
- if (psc->drawHash)
- __glxHashDestroy(psc->drawHash);
if (psc->driver)
dlclose(psc->driver);
}
if (psp == NULL)
return NULL;
- /* Create drawable hash */
- psc->drawHash = __glxHashCreate();
- if ( psc->drawHash == NULL )
- return NULL;
-
/* Initialize per screen dynamic client GLX extensions */
psc->ext_list_first_time = GL_TRUE;
};
struct __GLXDRIdrawableRec {
+ void (*destroyDrawable)(__GLXDRIdrawable *drawable);
+
XID drawable;
__GLXscreenConfigs *psc;
__DRIdrawable driDrawable;
if (!windowExistsFlag) {
/* Destroy the local drawable data, if the drawable no
longer exists in the Xserver */
- (*pdraw->driDrawable.destroyDrawable)(&pdraw->driDrawable);
- XF86DRIDestroyDrawable(dpy, sc->scr, draw);
+ (*pdraw->destroyDrawable)(pdraw);
__glxHashDelete(sc->drawHash, draw);
- Xfree(pdraw);
}
} while (__glxHashNext(sc->drawHash, &draw, (void *)&pdraw) == 1);
}
#ifdef GLX_DIRECT_RENDERING
if (psc->driScreen)
psc->driScreen->destroyScreen(psc);
+ if (psc->drawHash)
+ __glxHashDestroy(psc->drawHash);
#endif
}
XFree((char*) priv->screenConfigs);
psc->scr = i;
psc->dpy = dpy;
#ifdef GLX_DIRECT_RENDERING
- if (priv->driDisplay)
+ if (priv->driDisplay) {
+ /* Create drawable hash */
+ psc->drawHash = __glxHashCreate();
+ if (psc->drawHash == NULL)
+ continue;
psc->driScreen = (*priv->driDisplay->createScreen)(psc, i, priv);
+ if (psc->driScreen == NULL)
+ __glxHashDestroy(psc->drawHash);
+ }
#endif
}
SyncHandle();
if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0)
return pdraw;
- return psc->driScreen->createDrawable(psc, drawable, gc);
+ pdraw = psc->driScreen->createDrawable(psc, drawable, gc);
+ if (__glxHashInsert(psc->drawHash, drawable, pdraw)) {
+ (*pdraw->destroyDrawable)(pdraw);
+ return NULL;
+ }
+
+ return pdraw;
}
#endif /* GLX_DIRECT_RENDERING */