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 ()
 
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
403  : _Begin(0), _End(0)
404  { // construct with empty list
405  }
char * _Begin
Definition: allocators:440
char * _End
Definition: allocators:441

Member Function Documentation

template<size_t _Sz, size_t _Nelts = 20>
void* stdext::allocators::cache_suballoc< _Sz, _Nelts >::allocate ( size_t  _Count)
inline
408  { // pop from free list or suballocate
409  void *_Res = _Helper.pop();
410  if (_Res == 0)
411  { // free list empty, suballocate
412  if (_Begin == _End)
413  { // no room in block, allocate new block
414  if (_Count * _Nelts < sizeof (void *))
415  _Begin = (char*)::operator new(sizeof (void *));
416  else
417  _Begin = (char*)::operator new(_Count * _Nelts);
418 
419  _End = _Begin + _Count * _Nelts;
420  _Helper.allocated(_Nelts);
421  }
422  _Res = _Begin;
423  _Begin += _Count;
424  }
425  return (_Res);
426  }
freelist< _Sz, max_unbounded > _Helper
Definition: allocators:439
char * _Begin
Definition: allocators:440
_Diff _Count
Definition: algorithm:1941
char * _End
Definition: allocators:441
template<size_t _Sz, size_t _Nelts = 20>
void stdext::allocators::cache_suballoc< _Sz, _Nelts >::deallocate ( void _Ptr,
size_t   
)
inline
429  { // push onto free list
430  _Helper.push(_Ptr);
431  }
freelist< _Sz, max_unbounded > _Helper
Definition: allocators:439
template<size_t _Sz, size_t _Nelts = 20>
bool stdext::allocators::cache_suballoc< _Sz, _Nelts >::equals ( const cache_suballoc< _Sz, _Nelts > &  ) const
inline
434  { // report that caches can share data
435  return (true);
436  }

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: