STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Private Attributes | List of all members
stdext::allocators::cache_suballoc< _Sz, _Nelts > Class Template Reference

Public Member Functions

 cache_suballoc ()
 
_DECLSPEC_ALLOCATOR voidallocate (size_t _Count)
 
void deallocate (void *_Ptr, size_t)
 
bool equals (const cache_suballoc< _Sz, _Nelts > &) const
 

Private Attributes

freelist< _Sz, max_unbounded_Helper
 
char_Begin
 
char_End
 

Constructor & Destructor Documentation

template<size_t _Sz, size_t _Nelts = 20>
stdext::allocators::cache_suballoc< _Sz, _Nelts >::cache_suballoc ( )
inline
414  : _Begin(0), _End(0)
415  { // construct with empty list
416  }
char * _Begin
Definition: allocators:451
char * _End
Definition: allocators:452

Member Function Documentation

template<size_t _Sz, size_t _Nelts = 20>
_DECLSPEC_ALLOCATOR void* stdext::allocators::cache_suballoc< _Sz, _Nelts >::allocate ( size_t  _Count)
inline
419  { // pop from free list or suballocate
420  void *_Res = _Helper.pop();
421  if (_Res == 0)
422  { // free list empty, suballocate
423  if (_Begin == _End)
424  { // no room in block, allocate new block
425  if (_Count * _Nelts < sizeof (void *))
426  _Begin = (char*)::operator new(sizeof (void *));
427  else
428  _Begin = (char*)::operator new(_Count * _Nelts);
429 
430  _End = _Begin + _Count * _Nelts;
431  _Helper.allocated(_Nelts);
432  }
433  _Res = _Begin;
434  _Begin += _Count;
435  }
436  return (_Res);
437  }
freelist< _Sz, max_unbounded > _Helper
Definition: allocators:450
char * _Begin
Definition: allocators:451
_Diff _Count
Definition: algorithm:1941
char * _End
Definition: allocators:452
template<size_t _Sz, size_t _Nelts = 20>
void stdext::allocators::cache_suballoc< _Sz, _Nelts >::deallocate ( void _Ptr,
size_t   
)
inline
440  { // push onto free list
441  _Helper.push(_Ptr);
442  }
freelist< _Sz, max_unbounded > _Helper
Definition: allocators:450
template<size_t _Sz, size_t _Nelts = 20>
bool stdext::allocators::cache_suballoc< _Sz, _Nelts >::equals ( const cache_suballoc< _Sz, _Nelts > &  ) const
inline
445  { // report that caches can share data
446  return (true);
447  }

Member Data Documentation

template<size_t _Sz, size_t _Nelts = 20>
char* stdext::allocators::cache_suballoc< _Sz, _Nelts >::_Begin
private
template<size_t _Sz, size_t _Nelts = 20>
char* stdext::allocators::cache_suballoc< _Sz, _Nelts >::_End
private
template<size_t _Sz, size_t _Nelts = 20>
freelist<_Sz, max_unbounded> stdext::allocators::cache_suballoc< _Sz, _Nelts >::_Helper
private

The documentation for this class was generated from the following file: