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
410  : _Begin(0), _End(0)
411  { // construct with empty list
412  }
char * _Begin
Definition: allocators:447
char * _End
Definition: allocators:448

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
415  { // pop from free list or suballocate
416  void *_Res = _Helper.pop();
417  if (_Res == 0)
418  { // free list empty, suballocate
419  if (_Begin == _End)
420  { // no room in block, allocate new block
421  if (_Count * _Nelts < sizeof (void *))
422  _Begin = (char*)::operator new(sizeof (void *));
423  else
424  _Begin = (char*)::operator new(_Count * _Nelts);
425 
426  _End = _Begin + _Count * _Nelts;
427  _Helper.allocated(_Nelts);
428  }
429  _Res = _Begin;
430  _Begin += _Count;
431  }
432  return (_Res);
433  }
unsigned int _Count
Definition: xcomplex:668
freelist< _Sz, max_unbounded > _Helper
Definition: allocators:446
char * _Begin
Definition: allocators:447
char * _End
Definition: allocators:448
template<size_t _Sz, size_t _Nelts = 20>
void stdext::allocators::cache_suballoc< _Sz, _Nelts >::deallocate ( void _Ptr,
size_t   
)
inline
436  { // push onto free list
437  _Helper.push(_Ptr);
438  }
freelist< _Sz, max_unbounded > _Helper
Definition: allocators:446
template<size_t _Sz, size_t _Nelts = 20>
bool stdext::allocators::cache_suballoc< _Sz, _Nelts >::equals ( const cache_suballoc< _Sz, _Nelts > &  ) const
inline
441  { // report that caches can share data
442  return (true);
443  }

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: