egl: Implement _eglFiniDisplay.
authorChia-I Wu <olvaffe@gmail.com>
Mon, 10 Aug 2009 07:13:42 +0000 (15:13 +0800)
committerBrian Paul <brianp@vmware.com>
Wed, 12 Aug 2009 04:14:35 +0000 (22:14 -0600)
_eglFiniDisplay is called at exit time to free allocated displays.  It
is, however, not used right now.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/egl/main/egldisplay.c

index 58d935225c64a112206fdf684a5d2465d6a50d73..6fdb3b7a1c40e7dcf679d16fc18a535d41244700 100644 (file)
@@ -13,6 +13,7 @@
 #include "eglhash.h"
 #include "eglstring.h"
 #include "eglmutex.h"
+#include "egllog.h"
 
 
 static _EGL_DECLARE_MUTEX(_eglDisplayInitMutex);
@@ -29,7 +30,22 @@ _eglFiniDisplay(void)
 {
    _eglLockMutex(&_eglDisplayInitMutex);
    if (_eglDisplayHash) {
-      /* XXX TODO walk over table entries, deleting each */
+      EGLuint key = _eglHashFirstEntry(_eglDisplayHash);
+
+      while (key) {
+         _EGLDisplay *dpy = (_EGLDisplay *)
+            _eglHashLookup(_eglDisplayHash, key);
+         assert(dpy);
+
+         if (dpy->ContextList || dpy->SurfaceList)
+            _eglLog(_EGL_DEBUG, "Display %u is destroyed with resources", key);
+
+         _eglCleanupDisplay(dpy);
+         free(dpy);
+
+         key = _eglHashNextEntry(_eglDisplayHash, key);
+      }
+
       _eglDeleteHashTable(_eglDisplayHash);
       _eglDisplayHash = NULL;
       _eglDeleteHashTable(_eglSurfaceHash);