Files
MinecraftConsoles/Minecraft.Client/PS3/PS3Extras/TLSStorage.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

73 lines
1.2 KiB
C++

#include "stdafx.h"
TLSStoragePS3* TLSStoragePS3::m_pInstance = nullptr;
BOOL TLSStoragePS3::m_activeList[sc_maxSlots];
__thread LPVOID TLSStoragePS3::m_values[sc_maxSlots];
TLSStoragePS3::TLSStoragePS3()
{
for(int i=0;i<sc_maxSlots; i++)
{
m_activeList[i] = false;
m_values[i] = nullptr;
}
}
TLSStoragePS3* TLSStoragePS3::Instance()
{
if ( m_pInstance == 0 ) // Is this the first time?
{
m_pInstance = new TLSStoragePS3; // Create the singleton instance.
}
return m_pInstance;
}
int TLSStoragePS3::Alloc()
{
for(int i=0; i<sc_maxSlots; i++)
{
if(m_activeList[i] == false)
{
m_activeList[i] = true;
m_values[i] = nullptr;
return i;
}
}
assert(0); // we've ran out of slots
return -1;
}
BOOL TLSStoragePS3::Free( DWORD _index )
{
if(m_activeList[_index] == false)
return false; // not been allocated
m_activeList[_index] = false;
m_values[_index] = nullptr;
return true;
}
BOOL TLSStoragePS3::SetValue( DWORD _index, LPVOID _val )
{
if(m_activeList[_index] == false)
return false;
m_values[_index] = _val;
return true;
}
LPVOID TLSStoragePS3::GetValue( DWORD _index )
{
if(m_activeList[_index] == false)
return nullptr;
return m_values[_index];
}