Merge branch 'modesetting-gem' of ssh://git.freedesktop.org/git/mesa/drm into modeset...
[profile/ivi/libdrm.git] / libdrm / xf86drmHash.c
index 71d3d89..82cbc2a 100644 (file)
@@ -25,8 +25,6 @@
  *
  * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
  *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.4 2001/03/21 18:08:54 dawes Exp $
- *
  * DESCRIPTION
  *
  * This file contains a straightforward implementation of a fixed-sized
  *
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <stdio.h>
+#include <stdlib.h>
 
 #define HASH_MAIN 0
 
-#if HASH_MAIN
-# include <stdio.h>
-# include <stdlib.h>
-#else
-# include "drm.h"
+#if !HASH_MAIN
 # include "xf86drm.h"
-# ifdef XFree86LOADER
-#  include "xf86.h"
-#  include "xf86_ansic.h"
-# else
-#  include <stdio.h>
-#  include <stdlib.h>
-# endif
 #endif
 
 #define HASH_MAGIC 0xdeadbeef
@@ -292,14 +278,15 @@ int drmHashNext(void *t, unsigned long *key, void **value)
 {
     HashTablePtr  table = (HashTablePtr)t;
 
-    for (; table->p0 < HASH_SIZE;
-        ++table->p0, table->p1 = table->buckets[table->p0]) {
+    while (table->p0 < HASH_SIZE) {
        if (table->p1) {
            *key       = table->p1->key;
            *value     = table->p1->value;
            table->p1  = table->p1->next;
            return 1;
        }
+       table->p1 = table->buckets[table->p0];
+       ++table->p0;
     }
     return 0;
 }