gallium/util: replace pipe_mutex_lock() with mtx_lock()
[mesa.git] / src / gallium / auxiliary / util / u_keymap.c
index 01b17ddb1b31dcf4ec28885643cd75eaf8be538c..daa2991ced6b8f94fb4231827e202b15cd5fbee1 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 /**
  * Key lookup/associative container.
  *
- * Like Jose's u_hash_table, based on CSO cache code for now.
+ * Like Jose's util_hash_table, based on CSO cache code for now.
  *
  * Author: Brian Paul
  */
 
 
 #include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
-#include "pipe/p_error.h"
+#include "util/u_debug.h"
 
 #include "cso_cache/cso_hash.h"
 
@@ -72,7 +71,7 @@ default_delete_func(const struct keymap *map,
 }
 
 
-static INLINE struct keymap_item *
+static inline struct keymap_item *
 hash_table_item(struct cso_hash_iter iter)
 {
    return (struct keymap_item *) cso_hash_iter_data(iter);
@@ -144,7 +143,7 @@ util_delete_keymap(struct keymap *map, void *user)
 }
 
 
-static INLINE struct cso_hash_iter
+static inline struct cso_hash_iter
 hash_table_find_iter(const struct keymap *map, const void *key,
                      unsigned key_hash)
 {
@@ -163,7 +162,7 @@ hash_table_find_iter(const struct keymap *map, const void *key,
 }
 
 
-static INLINE struct keymap_item *
+static inline struct keymap_item *
 hash_table_find_item(const struct keymap *map, const void *key,
                      unsigned key_hash)
 {
@@ -194,6 +193,8 @@ util_keymap_insert(struct keymap *map, const void *key,
    struct cso_hash_iter iter;
 
    assert(map);
+   if (!map)
+      return FALSE;
 
    key_hash = hash(key, map->key_size);
 
@@ -234,6 +235,8 @@ util_keymap_lookup(const struct keymap *map, const void *key)
    struct keymap_item *item;
 
    assert(map);
+   if (!map)
+      return NULL;
 
    key_hash = hash(key, map->key_size);
 
@@ -258,6 +261,8 @@ util_keymap_remove(struct keymap *map, const void *key, void *user)
    struct keymap_item *item;
 
    assert(map);
+   if (!map)
+      return;
 
    key_hash = hash(key, map->key_size);
 
@@ -267,6 +272,8 @@ util_keymap_remove(struct keymap *map, const void *key, void *user)
    
    item = hash_table_item(iter);
    assert(item);
+   if (!item)
+      return;
    map->delete_func(map, item->key, item->value, user);
    FREE(item->key);
    FREE(item);
@@ -288,7 +295,9 @@ util_keymap_remove_all(struct keymap *map, void *user)
    struct keymap_item *item;
 
    assert(map);
-   
+   if (!map)
+      return;
+
    iter = cso_hash_first_node(map->cso);
    while (!cso_hash_iter_is_null(iter)) {
       item = (struct keymap_item *)