diff options
author | Chris Robinson <[email protected]> | 2018-01-28 00:53:21 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-28 00:53:21 -0800 |
commit | d1da9f1f679e94b3aa05c9d9d981c63e145399a5 (patch) | |
tree | 4d67431d8ccab7ff7e813ac2f7e6ccd2520f00db /common | |
parent | dcc5a10c7b8bbe6be82c992b6540fd1ad745b7a7 (diff) |
Remove some now-unused NoLock function variants
Diffstat (limited to 'common')
-rw-r--r-- | common/uintmap.c | 132 | ||||
-rw-r--r-- | common/uintmap.h | 17 |
2 files changed, 5 insertions, 144 deletions
diff --git a/common/uintmap.c b/common/uintmap.c index be628a5f..18d52d64 100644 --- a/common/uintmap.c +++ b/common/uintmap.c @@ -119,81 +119,6 @@ ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value) return AL_NO_ERROR; } -ALenum InsertUIntMapEntryNoLock(UIntMap *map, ALuint key, ALvoid *value) -{ - ALsizei pos = 0; - - if(map->size > 0) - { - ALsizei count = map->size; - do { - ALsizei step = count>>1; - ALsizei i = pos+step; - if(!(map->keys[i] < key)) - count = step; - else - { - pos = i+1; - count -= step+1; - } - } while(count > 0); - } - - if(pos == map->size || map->keys[pos] != key) - { - if(map->size >= map->limit) - return AL_OUT_OF_MEMORY; - - if(map->size == map->capacity) - { - ALuint *keys = NULL; - ALvoid **values; - ALsizei newcap, keylen; - - newcap = (map->capacity ? (map->capacity<<1) : 4); - if(map->limit > 0 && newcap > map->limit) - newcap = map->limit; - if(newcap > map->capacity) - { - /* Round the memory size for keys up to a multiple of the - * pointer size. - */ - keylen = newcap * sizeof(map->keys[0]); - keylen += sizeof(map->values[0]) - 1; - keylen -= keylen%sizeof(map->values[0]); - - keys = al_malloc(16, keylen + newcap*sizeof(map->values[0])); - } - if(!keys) - return AL_OUT_OF_MEMORY; - values = (ALvoid**)((ALbyte*)keys + keylen); - - if(map->keys) - { - memcpy(keys, map->keys, map->size*sizeof(map->keys[0])); - memcpy(values, map->values, map->size*sizeof(map->values[0])); - } - al_free(map->keys); - map->keys = keys; - map->values = values; - map->capacity = newcap; - } - - if(pos < map->size) - { - memmove(&map->keys[pos+1], &map->keys[pos], - (map->size-pos)*sizeof(map->keys[0])); - memmove(&map->values[pos+1], &map->values[pos], - (map->size-pos)*sizeof(map->values[0])); - } - map->size++; - } - map->keys[pos] = key; - map->values[pos] = value; - - return AL_NO_ERROR; -} - ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key) { ALvoid *ptr = NULL; @@ -230,40 +155,6 @@ ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key) return ptr; } -ALvoid *RemoveUIntMapKeyNoLock(UIntMap *map, ALuint key) -{ - ALvoid *ptr = NULL; - if(map->size > 0) - { - ALsizei pos = 0; - ALsizei count = map->size; - do { - ALsizei step = count>>1; - ALsizei i = pos+step; - if(!(map->keys[i] < key)) - count = step; - else - { - pos = i+1; - count -= step+1; - } - } while(count > 0); - if(pos < map->size && map->keys[pos] == key) - { - ptr = map->values[pos]; - if(pos < map->size-1) - { - memmove(&map->keys[pos], &map->keys[pos+1], - (map->size-1-pos)*sizeof(map->keys[0])); - memmove(&map->values[pos], &map->values[pos+1], - (map->size-1-pos)*sizeof(map->values[0])); - } - map->size--; - } - } - return ptr; -} - ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key) { ALvoid *ptr = NULL; @@ -289,26 +180,3 @@ ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key) ReadUnlock(&map->lock); return ptr; } - -ALvoid *LookupUIntMapKeyNoLock(UIntMap *map, ALuint key) -{ - if(map->size > 0) - { - ALsizei pos = 0; - ALsizei count = map->size; - do { - ALsizei step = count>>1; - ALsizei i = pos+step; - if(!(map->keys[i] < key)) - count = step; - else - { - pos = i+1; - count -= step+1; - } - } while(count > 0); - if(pos < map->size && map->keys[pos] == key) - return map->values[pos]; - } - return NULL; -} diff --git a/common/uintmap.h b/common/uintmap.h index 32cd1eaa..32868653 100644 --- a/common/uintmap.h +++ b/common/uintmap.h @@ -26,20 +26,13 @@ typedef struct UIntMap { void InitUIntMap(UIntMap *map, ALsizei limit); void ResetUIntMap(UIntMap *map); ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); -ALenum InsertUIntMapEntryNoLock(UIntMap *map, ALuint key, ALvoid *value); ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key); -ALvoid *RemoveUIntMapKeyNoLock(UIntMap *map, ALuint key); ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key); -ALvoid *LookupUIntMapKeyNoLock(UIntMap *map, ALuint key); - -inline void LockUIntMapRead(UIntMap *map) -{ ReadLock(&map->lock); } -inline void UnlockUIntMapRead(UIntMap *map) -{ ReadUnlock(&map->lock); } -inline void LockUIntMapWrite(UIntMap *map) -{ WriteLock(&map->lock); } -inline void UnlockUIntMapWrite(UIntMap *map) -{ WriteUnlock(&map->lock); } + +inline void LockUIntMapRead(UIntMap *map) { ReadLock(&map->lock); } +inline void UnlockUIntMapRead(UIntMap *map) { ReadUnlock(&map->lock); } +inline void LockUIntMapWrite(UIntMap *map) { WriteLock(&map->lock); } +inline void UnlockUIntMapWrite(UIntMap *map) { WriteUnlock(&map->lock); } #ifdef __cplusplus } |