2013-10-28 19:48:13 +00:00
|
|
|
#ifndef AL_UINTMAP_H
|
|
|
|
#define AL_UINTMAP_H
|
|
|
|
|
2017-08-30 19:01:49 +00:00
|
|
|
#include <limits.h>
|
|
|
|
|
2013-10-28 19:48:13 +00:00
|
|
|
#include "AL/al.h"
|
|
|
|
#include "rwlock.h"
|
|
|
|
|
2014-05-29 11:22:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-10-28 19:48:13 +00:00
|
|
|
typedef struct UIntMap {
|
2016-07-05 03:35:32 +00:00
|
|
|
ALuint *keys;
|
|
|
|
/* Shares memory with keys. */
|
|
|
|
ALvoid **values;
|
|
|
|
|
2013-10-28 19:48:13 +00:00
|
|
|
ALsizei size;
|
2016-07-04 16:18:49 +00:00
|
|
|
ALsizei capacity;
|
2013-10-28 19:48:13 +00:00
|
|
|
ALsizei limit;
|
|
|
|
RWLock lock;
|
|
|
|
} UIntMap;
|
2016-07-05 03:35:32 +00:00
|
|
|
#define UINTMAP_STATIC_INITIALIZE_N(_n) { NULL, NULL, 0, 0, (_n), RWLOCK_STATIC_INITIALIZE }
|
2017-04-15 05:56:54 +00:00
|
|
|
#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(INT_MAX)
|
2013-10-28 19:48:13 +00:00
|
|
|
|
|
|
|
void InitUIntMap(UIntMap *map, ALsizei limit);
|
|
|
|
void ResetUIntMap(UIntMap *map);
|
2017-04-15 05:56:54 +00:00
|
|
|
void RelimitUIntMapNoLock(UIntMap *map, ALsizei limit);
|
2013-10-28 19:48:13 +00:00
|
|
|
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
|
2017-03-28 06:16:23 +00:00
|
|
|
ALenum InsertUIntMapEntryNoLock(UIntMap *map, ALuint key, ALvoid *value);
|
2013-10-28 19:48:13 +00:00
|
|
|
ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key);
|
2016-05-11 05:49:24 +00:00
|
|
|
ALvoid *RemoveUIntMapKeyNoLock(UIntMap *map, ALuint key);
|
2013-10-28 19:48:13 +00:00
|
|
|
ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key);
|
2016-05-11 05:49:24 +00:00
|
|
|
ALvoid *LookupUIntMapKeyNoLock(UIntMap *map, ALuint key);
|
2013-10-28 19:48:13 +00:00
|
|
|
|
2013-11-04 20:12:31 +00:00
|
|
|
inline void LockUIntMapRead(UIntMap *map)
|
2013-10-28 19:48:13 +00:00
|
|
|
{ ReadLock(&map->lock); }
|
2013-11-04 20:12:31 +00:00
|
|
|
inline void UnlockUIntMapRead(UIntMap *map)
|
2013-10-28 19:48:13 +00:00
|
|
|
{ ReadUnlock(&map->lock); }
|
2013-11-04 20:12:31 +00:00
|
|
|
inline void LockUIntMapWrite(UIntMap *map)
|
2013-10-28 19:48:13 +00:00
|
|
|
{ WriteLock(&map->lock); }
|
2013-11-04 20:12:31 +00:00
|
|
|
inline void UnlockUIntMapWrite(UIntMap *map)
|
2013-10-28 19:48:13 +00:00
|
|
|
{ WriteUnlock(&map->lock); }
|
|
|
|
|
2014-05-29 11:22:30 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-10-28 19:48:13 +00:00
|
|
|
#endif /* AL_UINTMAP_H */
|