#include "config.h" #include "runtime.h" #include "threading.h" #include #include #define VY_MAX_CVARS 1024 static vy_cvar *_vars[VY_MAX_CVARS]; static unsigned int _next = 0; static vy_mutex *_mutex = NULL; void vyRegisterCVAR(vy_cvar *cvar) { if (!_mutex) _mutex = vyCreateMutex(); vyLockMutex(_mutex); if (_next < VY_MAX_CVARS) { _vars[_next++] = cvar; } else { vyReportError("cvar", "Ran out of space for CVars"); } vyUnlockMutex(_mutex); } vy_cvar *vyGetCVAR(const char *name) { if (!_mutex) _mutex = vyCreateMutex(); vy_cvar *var = NULL; vyLockMutex(_mutex); for (unsigned int i = 0; i < _next; ++i) { if (strcmp(name, _vars[i]->name) == 0) { var = _vars[i]; break; } } vyUnlockMutex(_mutex); return var; }