X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Futil%2Fu_handle_table.c;h=85302f1e1942dc4374ddf43732848e8009d36957;hb=f8ba0f55d32274eb2fe0e0060658dc2284569dd4;hp=6da7353e259a92b565dbf6da3987d21bc0621d81;hpb=76d8951fd3adbb91b2f71d461eec0f304619ca0b;p=mesa.git diff --git a/src/gallium/auxiliary/util/u_handle_table.c b/src/gallium/auxiliary/util/u_handle_table.c index 6da7353e259..85302f1e194 100644 --- a/src/gallium/auxiliary/util/u_handle_table.c +++ b/src/gallium/auxiliary/util/u_handle_table.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. @@ -29,7 +29,7 @@ * @file * Generic handle table implementation. * - * @author José Fonseca + * @author José Fonseca */ @@ -87,6 +87,8 @@ handle_table_set_destroy(struct handle_table *ht, void (*destroy)(void *object)) { assert(ht); + if (!ht) + return; ht->destroy = destroy; } @@ -155,7 +157,7 @@ handle_table_add(struct handle_table *ht, assert(ht); assert(object); - if(!object) + if(!object || !ht) return 0; /* linear search for an empty handle */ @@ -193,7 +195,7 @@ handle_table_set(struct handle_table *ht, assert(ht); assert(handle); - if(!handle) + if(!handle || !ht) return 0; assert(object); @@ -222,7 +224,7 @@ handle_table_get(struct handle_table *ht, assert(ht); assert(handle); - if(!handle || handle > ht->size) + if(!handle || !ht || handle > ht->size) return NULL; object = ht->objects[handle - 1]; @@ -240,7 +242,7 @@ handle_table_remove(struct handle_table *ht, assert(ht); assert(handle); - if(!handle || handle > ht->size) + if(!handle || !ht || handle > ht->size) return; index = handle - 1; @@ -283,6 +285,9 @@ handle_table_destroy(struct handle_table *ht) unsigned index; assert(ht); + if (!ht) + return; + if(ht->destroy) for(index = 0; index < ht->size; ++index) handle_table_clear(ht, index);