diff options
Diffstat (limited to 'common/uintmap.c')
-rw-r--r-- | common/uintmap.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/common/uintmap.c b/common/uintmap.c index b7a9a29c..d5e7c9ae 100644 --- a/common/uintmap.c +++ b/common/uintmap.c @@ -120,6 +120,33 @@ ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key) return ptr; } +ALvoid *RemoveUIntMapKeyNoLock(UIntMap *map, ALuint key) +{ + if(map->size > 0) + { + ALsizei low = 0; + ALsizei high = map->size - 1; + while(low < high) + { + ALsizei mid = low + (high-low)/2; + if(map->array[mid].key < key) + low = mid + 1; + else + high = mid; + } + if(map->array[low].key == key) + { + ALvoid *ptr = map->array[low].value; + if(low < map->size-1) + memmove(&map->array[low], &map->array[low+1], + (map->size-1-low)*sizeof(map->array[0])); + map->size--; + return ptr; + } + } + return NULL; +} + ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key) { ALvoid *ptr = NULL; @@ -142,3 +169,23 @@ ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key) ReadUnlock(&map->lock); return ptr; } + +ALvoid *LookupUIntMapKeyNoLock(UIntMap *map, ALuint key) +{ + if(map->size > 0) + { + ALsizei low = 0; + ALsizei high = map->size - 1; + while(low < high) + { + ALsizei mid = low + (high-low)/2; + if(map->array[mid].key < key) + low = mid + 1; + else + high = mid; + } + if(map->array[low].key == key) + return map->array[low].value; + } + return NULL; +} |