2013-10-28 12:48:13 -07:00
|
|
|
#ifndef AL_UINTMAP_H
|
|
|
|
#define AL_UINTMAP_H
|
|
|
|
|
2017-08-30 12:01:49 -07:00
|
|
|
#include <limits.h>
|
|
|
|
|
2013-10-28 12:48:13 -07:00
|
|
|
#include "AL/al.h"
|
|
|
|
#include "rwlock.h"
|
|
|
|
|
2014-05-29 04:22:30 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-10-28 12:48:13 -07:00
|
|
|
typedef struct UIntMap {
|
2016-07-04 20:35:32 -07:00
|
|
|
ALuint *keys;
|
|
|
|
/* Shares memory with keys. */
|
|
|
|
ALvoid **values;
|
|
|
|
|
2013-10-28 12:48:13 -07:00
|
|
|
ALsizei size;
|
2016-07-04 09:18:49 -07:00
|
|
|
ALsizei capacity;
|
2013-10-28 12:48:13 -07:00
|
|
|
ALsizei limit;
|
|
|
|
RWLock lock;
|
|
|
|
} UIntMap;
|
2016-07-04 20:35:32 -07:00
|
|
|
#define UINTMAP_STATIC_INITIALIZE_N(_n) { NULL, NULL, 0, 0, (_n), RWLOCK_STATIC_INITIALIZE }
|
2017-04-14 22:56:54 -07:00
|
|
|
#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(INT_MAX)
|
2013-10-28 12:48:13 -07:00
|
|
|
|
|
|
|
void InitUIntMap(UIntMap *map, ALsizei limit);
|
|
|
|
void ResetUIntMap(UIntMap *map);
|
|
|
|
ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value);
|
|
|
|
ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key);
|
|
|
|
ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key);
|
2018-01-28 00:53:21 -08:00
|
|
|
|
|
|
|
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); }
|
2013-10-28 12:48:13 -07:00
|
|
|
|
2014-05-29 04:22:30 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-10-28 12:48:13 -07:00
|
|
|
#endif /* AL_UINTMAP_H */
|