+}
+
+
+/**
+ * Return EGL_TRUE if the given handle is a valid handle to a display.
+ */
+EGLBoolean
+_eglCheckDisplayHandle(EGLDisplay dpy)
+{
+ _EGLDisplay *cur;
+
+ _eglLockMutex(_eglGlobal.Mutex);
+ cur = _eglGlobal.DisplayList;
+ while (cur) {
+ if (cur == (_EGLDisplay *) dpy)
+ break;
+ cur = cur->Next;
+ }
+ _eglUnlockMutex(_eglGlobal.Mutex);
+ return (cur != NULL);
+}
+
+
+/**
+ * Return EGL_TRUE if the given resource is valid. That is, the display does
+ * own the resource.
+ */
+EGLBoolean
+_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy)
+{
+ _EGLResource *list = dpy->ResourceLists[type];
+
+ if (!res)
+ return EGL_FALSE;
+
+ while (list) {
+ if (res == (void *) list) {
+ assert(list->Display == dpy);
+ break;
+ }
+ list = list->Next;
+ }
+
+ return (list != NULL);
+}
+