{
XMesaExtDisplayInfo *info, *prev;
+ /* These assertions are not valid since screen creation can fail and result
+ * in an empty list
assert(MesaExtInfo.ndisplays > 0);
assert(MesaExtInfo.head);
+ */
_XLockMutex(_Xglobal_lock);
/* first find display */
return NULL;
}
info->display = display;
+
xmdpy = &info->mesaDisplay; /* to be filled out below */
+ xmdpy->display = display;
+ xmdpy->pipe = NULL;
+
+ xmdpy->smapi = CALLOC_STRUCT(st_manager);
+ if (!xmdpy->smapi) {
+ Xfree(info);
+ mtx_unlock(&init_mutex);
+ return NULL;
+ }
+
+ xmdpy->screen = driver.create_pipe_screen(display);
+ if (!xmdpy->screen) {
+ free(xmdpy->smapi);
+ Xfree(info);
+ mtx_unlock(&init_mutex);
+ return NULL;
+ }
+
+ /* At this point, both smapi and screen are known to be valid */
+ xmdpy->smapi->screen = xmdpy->screen;
+ xmdpy->smapi->get_param = xmesa_get_param;
+ (void) mtx_init(&xmdpy->mutex, mtx_plain);
/* chain to the list of displays */
_XLockMutex(_Xglobal_lock);
MesaExtInfo.ndisplays++;
_XUnlockMutex(_Xglobal_lock);
- /* now create the new XMesaDisplay info */
- assert(display);
-
- xmdpy->display = display;
- xmdpy->screen = driver.create_pipe_screen(display);
- xmdpy->smapi = CALLOC_STRUCT(st_manager);
- xmdpy->pipe = NULL;
- if (xmdpy->smapi) {
- xmdpy->smapi->screen = xmdpy->screen;
- xmdpy->smapi->get_param = xmesa_get_param;
- }
-
- if (xmdpy->screen && xmdpy->smapi) {
- (void) mtx_init(&xmdpy->mutex, mtx_plain);
- }
- else {
- if (xmdpy->screen) {
- xmdpy->screen->destroy(xmdpy->screen);
- xmdpy->screen = NULL;
- }
- free(xmdpy->smapi);
- xmdpy->smapi = NULL;
-
- xmdpy->display = NULL;
- }
-
mtx_unlock(&init_mutex);
return xmdpy;
/**
* Do per-display initializations.
*/
-void
+int
xmesa_init( Display *display )
{
- xmesa_init_display(display);
+ return xmesa_init_display(display) ? 0 : 1;
}