This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
| 1 |
/* |
| 2 |
* Copyright (c) 2011 |
| 3 |
* Petr Ovtchenkov |
| 4 |
* |
| 5 |
* This material is provided "as is", with absolutely no warranty expressed |
| 6 |
* or implied. Any use is at your own risk. |
| 7 |
* |
| 8 |
* Permission to use or copy this software for any purpose is hereby granted |
| 9 |
* without fee, provided the above notices are retained on all copies. |
| 10 |
* Permission to modify the code and to distribute modified code is granted, |
| 11 |
* provided the above notices are retained, and a notice that the code was |
| 12 |
* modified is included with the above copyright notice. |
| 13 |
* |
| 14 |
*/ |
| 15 |
|
| 16 |
#include <memory> |
| 17 |
#include <unordered_map> |
| 18 |
|
| 19 |
_STLP_BEGIN_NAMESPACE |
| 20 |
|
| 21 |
namespace detail { |
| 22 |
|
| 23 |
static unordered_map<void*,unsigned long> _reachable; |
| 24 |
|
| 25 |
void* __undeclare_reachable( void* p ) noexcept |
| 26 |
{ |
| 27 |
auto i = _reachable.find( p ); |
| 28 |
if ( i != _reachable.end() ) { |
| 29 |
if ( --i->second == 0 ) { |
| 30 |
_reachable.erase( i ); |
| 31 |
} |
| 32 |
return p; |
| 33 |
} |
| 34 |
|
| 35 |
return NULL; |
| 36 |
} |
| 37 |
|
| 38 |
} // detail |
| 39 |
|
| 40 |
void declare_reachable( void* p ) |
| 41 |
{ |
| 42 |
if ( p != NULL ) { |
| 43 |
++detail::_reachable[p]; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
void declare_no_pointers( char* /* p */, size_t /* n */ ) noexcept |
| 48 |
{ |
| 49 |
} |
| 50 |
|
| 51 |
void undeclare_no_pointers( char* /* p */, size_t /* n */ ) noexcept |
| 52 |
{ |
| 53 |
} |
| 54 |
|
| 55 |
pointer_safety get_pointer_safety() noexcept |
| 56 |
{ |
| 57 |
return pointer_safety::relaxed; |
| 58 |
} |
| 59 |
|
| 60 |
_STLP_END_NAMESPACE |