tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

PoolAlloc.cpp (936B)


      1 //
      2 // Copyright 2002 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 
      7 #include "compiler/translator/PoolAlloc.h"
      8 
      9 #include "common/debug.h"
     10 #include "common/tls.h"
     11 
     12 TLSIndex PoolIndex = TLS_INVALID_INDEX;
     13 
     14 bool InitializePoolIndex()
     15 {
     16    ASSERT(PoolIndex == TLS_INVALID_INDEX);
     17 
     18    PoolIndex = CreateTLSIndex(nullptr);
     19    return PoolIndex != TLS_INVALID_INDEX;
     20 }
     21 
     22 void FreePoolIndex()
     23 {
     24    ASSERT(PoolIndex != TLS_INVALID_INDEX);
     25 
     26    DestroyTLSIndex(PoolIndex);
     27    PoolIndex = TLS_INVALID_INDEX;
     28 }
     29 
     30 angle::PoolAllocator *GetGlobalPoolAllocator()
     31 {
     32    ASSERT(PoolIndex != TLS_INVALID_INDEX);
     33    return static_cast<angle::PoolAllocator *>(GetTLSValue(PoolIndex));
     34 }
     35 
     36 void SetGlobalPoolAllocator(angle::PoolAllocator *poolAllocator)
     37 {
     38    ASSERT(PoolIndex != TLS_INVALID_INDEX);
     39    SetTLSValue(PoolIndex, poolAllocator);
     40 }