X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgallium%2Fauxiliary%2Futil%2Fu_keymap.c;h=daa2991ced6b8f94fb4231827e202b15cd5fbee1;hb=b284f1f7f9afa560d6f4c0863681a7e36913955c;hp=3f70809efdc6868e161be4aabf75f8d12178316d;hpb=407e8ae5b167b0193e1e5b1266a5d61ed836dfb5;p=mesa.git diff --git a/src/gallium/auxiliary/util/u_keymap.c b/src/gallium/auxiliary/util/u_keymap.c index 3f70809efdc..daa2991ced6 100644 --- a/src/gallium/auxiliary/util/u_keymap.c +++ b/src/gallium/auxiliary/util/u_keymap.c @@ -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. @@ -28,7 +28,7 @@ /** * 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 */ @@ -36,7 +36,6 @@ #include "pipe/p_compiler.h" #include "util/u_debug.h" -#include "pipe/p_error.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 *)