aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-10-06 06:39:13 -0700
committerChris Robinson <[email protected]>2011-10-06 06:39:13 -0700
commit81133769def858c663718dc3e676d288594e0d66 (patch)
tree47ece23d7143a64c4c08fe109335a59a71fc7077 /Alc
parenta7d3779dfafbc7b5011ea7d1b252d94daed969f6 (diff)
Return the key's value from the map when it's removed
Diffstat (limited to 'Alc')
-rw-r--r--Alc/helpers.c34
1 files changed, 4 insertions, 30 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index 980c0071..f219f4ae 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -391,8 +391,9 @@ ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value)
return AL_NO_ERROR;
}
-void RemoveUIntMapKey(UIntMap *map, ALuint key)
+ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key)
{
+ ALvoid *ptr = NULL;
WriteLock(&map->lock);
if(map->size > 0)
{
@@ -408,6 +409,7 @@ void RemoveUIntMapKey(UIntMap *map, ALuint key)
}
if(map->array[low].key == key)
{
+ 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]));
@@ -415,6 +417,7 @@ void RemoveUIntMapKey(UIntMap *map, ALuint key)
}
}
WriteUnlock(&map->lock);
+ return ptr;
}
ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key)
@@ -439,32 +442,3 @@ ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key)
ReadUnlock(&map->lock);
return ptr;
}
-
-ALvoid *PopUIntMapValue(UIntMap *map, ALuint key)
-{
- ALvoid *ptr = NULL;
- WriteLock(&map->lock);
- 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)
- {
- 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--;
- }
- }
- WriteUnlock(&map->lock);
- return ptr;
-}