Changeset 281


Ignore:
Timestamp:
Dec 10, 2002, 8:10:49 PM (18 years ago)
Author:
pooh
Message:
  • Added allocator features.
Location:
to-imperative/trunk/libp++
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/libp++/pxx_allocator.hh

    r277 r281  
    3030{
    3131
     32#define ALLOCATOR_HAS_GET_REAL_SIZE             0x0001
     33#define ALLOCATOR_HAS_GET_BLOCK                 0x0002
     34#define ALLOCATOR_HAS_GET_BLOCK_WITH_SIZE       0x0004
     35
    3236//
    3337// Generic allocator interface
     
    3640
    3741protected:
     42  //
     43  // Allocator features
     44  unsigned features ;
     45  //
    3846  NO_COPY_CTOR(Allocator)
    3947  NO_ASSIGN(Allocator)
     
    4351  //
    4452  // Constructor
    45   Allocator () {}
     53  Allocator (unsigned _features = 0) : features (_features) {}
    4654  //
    4755  // Virtual destructor
     
    6775  // The same as previous, but using block size
    6876  virtual void* get_block (void* _ptr, size_t _size) = 0 ;
     77  //
     78  // Get allocator features
     79  unsigned get_features () const { return features; }
    6980
    7081};
  • to-imperative/trunk/libp++/pxx_default_allocator.ih

    r277 r281  
    9090inline void DefaultAllocator::set (Allocator& _allocator)
    9191{
    92   if (allocator == null)
     92  if (allocator == null) {
    9393    allocator = &_allocator;
    94   else if (allocator == &default_malloc_allocator)
     94    features = _allocator.get_features();
     95  } else if (allocator == &default_malloc_allocator)
    9596    FATAL("Default malloc allocator already was used");
    9697  else
  • to-imperative/trunk/libp++/pxx_heap_allocator.cc

    r272 r281  
    4141  int _fd /* = -1 */
    4242) :
     43  Allocator (
     44    ALLOCATOR_HAS_GET_REAL_SIZE |
     45    ALLOCATOR_HAS_GET_BLOCK | ALLOCATOR_HAS_GET_BLOCK_WITH_SIZE
     46  ),
    4347  Heap (_init_size, _max_size, _start, _fd)
    4448{
Note: See TracChangeset for help on using the changeset viewer.