fix some 0->NULLs
[mesa.git] / src / mesa / drivers / dri / common / dri_util.c
index 33facbbf6c6bf44c57299644073796376116b410..302994e0c23a9417fe0d48dace5177c0ecfc47b5 100644 (file)
@@ -25,8 +25,6 @@
  */
 
 
-#ifdef GLX_DIRECT_RENDERING
-
 #include <assert.h>
 #include <stdarg.h>
 #include <unistd.h>
@@ -235,34 +233,13 @@ static GLboolean __driAddDrawable(void *drawHash, __DRIdrawable *pdraw)
 static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw)
 {
     int retcode;
-    union 
-    {
-       __DRIdrawable *pdraw;
-       void *ptr;
-    } p;
+    __DRIdrawable *pdraw;
 
-    retcode = drmHashLookup(drawHash, draw, &p.ptr);
+    retcode = drmHashLookup(drawHash, draw, (void *)&pdraw);
     if (retcode)
        return NULL;
 
-    return p.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);
-    }
+    return pdraw;
 }
 
 #ifndef DRI_NEW_INTERFACE_ONLY
@@ -320,24 +297,20 @@ static void __driGarbageCollectDrawables(void *drawHash)
 {
     __DRIid draw;
     __DRInativeDisplay *dpy;
-    union 
-    {
-       __DRIdrawable *pdraw;
-       void *ptr;
-    } p;
+    __DRIdrawable *pdraw;
 
-    if (drmHashFirst(drawHash, &draw, &p.ptr)) {
+    if (drmHashFirst(drawHash, &draw, (void *)&pdraw) == 1) {
        do {
-           __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)p.pdraw->private;
+           __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
            dpy = pdp->driScreenPriv->display;
            if (! (*window_exists)(dpy, draw)) {
                /* Destroy the local drawable data in the hash table, if the
                   drawable no longer exists in the Xserver */
-               __driRemoveDrawable(drawHash, p.pdraw);
-               (*p.pdraw->destroyDrawable)(dpy, p.pdraw->private);
-               _mesa_free(p.pdraw);
+               drmHashDelete(drawHash, draw);
+               (*pdraw->destroyDrawable)(dpy, pdraw->private);
+               _mesa_free(pdraw);
            }
-       } while (drmHashNext(drawHash, &draw, &p.ptr));
+       } while (drmHashNext(drawHash, &draw, (void *)&pdraw) == 1);
     }
 }
 
@@ -1600,7 +1573,7 @@ __driUtilCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
  *
  * \sa __glXGetInternalVersion().
  */
-int driCompareGLXAPIVersion( GLuint required_version )
+int driCompareGLXAPIVersion( GLint required_version )
 {
    if ( api_ver > required_version ) {
       return 1;
@@ -1714,5 +1687,3 @@ driCalculateSwapUsage( __DRIdrawablePrivate *dPriv, int64_t last_swap_ust,
 }
 
 /*@}*/
-
-#endif /* GLX_DIRECT_RENDERING */