aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/uintmap.c9
-rw-r--r--common/uintmap.h3
2 files changed, 9 insertions, 3 deletions
diff --git a/common/uintmap.c b/common/uintmap.c
index 21a921b2..98ed3191 100644
--- a/common/uintmap.c
+++ b/common/uintmap.c
@@ -36,6 +36,11 @@ void ResetUIntMap(UIntMap *map)
WriteUnlock(&map->lock);
}
+void RelimitUIntMapNoLock(UIntMap *map, ALsizei limit)
+{
+ map->limit = limit;
+}
+
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value)
{
ALsizei pos = 0;
@@ -59,7 +64,7 @@ ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value)
if(pos == map->size || map->keys[pos] != key)
{
- if(map->size == map->limit)
+ if(map->size >= map->limit)
{
WriteUnlock(&map->lock);
return AL_OUT_OF_MEMORY;
@@ -141,7 +146,7 @@ ALenum InsertUIntMapEntryNoLock(UIntMap *map, ALuint key, ALvoid *value)
if(pos == map->size || map->keys[pos] != key)
{
- if(map->size == map->limit)
+ if(map->size >= map->limit)
return AL_OUT_OF_MEMORY;
if(map->size == map->capacity)
diff --git a/common/uintmap.h b/common/uintmap.h
index f70d99fd..47bd0d42 100644
--- a/common/uintmap.h
+++ b/common/uintmap.h
@@ -19,10 +19,11 @@ typedef struct UIntMap {
RWLock lock;
} UIntMap;
#define UINTMAP_STATIC_INITIALIZE_N(_n) { NULL, NULL, 0, 0, (_n), RWLOCK_STATIC_INITIALIZE }
-#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(~0)
+#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(INT_MAX)
void InitUIntMap(UIntMap *map, ALsizei limit);
void ResetUIntMap(UIntMap *map);
+void RelimitUIntMapNoLock(UIntMap *map, ALsizei limit);
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
ALenum InsertUIntMapEntryNoLock(UIntMap *map, ALuint key, ALvoid *value);
ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key);