Changeset 275


Ignore:
Timestamp:
Dec 9, 2002, 8:47:17 PM (18 years ago)
Author:
pooh
Message:
  • Added get_real_size() method.
Location:
to-imperative/trunk/libp++
Files:
7 edited

Legend:

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

    r270 r275  
    5656  // Resize memory block at _ptr to _size bytes
    5757  virtual void* reallocate (void* _ptr, size_t _size) = 0 ;
     58  //
     59  // Returns (if possible) a real size (probably larger then given)
     60  // of memory block to be allocated
     61  virtual size_t get_real_size (size_t _size) = 0 ;
    5862
    5963};
  • to-imperative/trunk/libp++/pxx_default_allocator.hh

    r274 r275  
    7070  // Set real allocator to use
    7171  inline void set (Allocator& _allocator) ;
     72  //
     73  // Returns (if possible) a real size (probably larger then given)
     74  // of memory block to be allocated
     75  inline size_t get_real_size (size_t _size) ;
    7276
    7377};
  • to-imperative/trunk/libp++/pxx_default_allocator.ih

    r274 r275  
    6060}
    6161
     62inline size_t DefaultAllocator::get_real_size (size_t _size)
     63{
     64  if (allocator == null) set(default_malloc_allocator);
     65  return allocator->get_real_size(_size);
     66}
     67
    6268inline Allocator& DefaultAllocator::get ()
    6369{
  • to-imperative/trunk/libp++/pxx_heap_allocator.hh

    r271 r275  
    122122  void* reallocate (void* _ptr, size_t _size) ;
    123123  //
     124  // Returns (if possible) a real size (probably larger then given)
     125  // of memory block to be allocated
     126  inline size_t get_real_size (size_t _size) ;
     127  //
    124128  // Get a size of allocated memory block
    125129  inline size_t get_size (void* _ptr) ;
  • to-imperative/trunk/libp++/pxx_heap_allocator.ih

    r271 r275  
    8080}
    8181
     82//
     83// Returns (if possible) a real size (probably larger then given)
     84// of memory block to be allocated
     85inline size_t HeapAllocator::get_real_size (size_t _size)
     86{
     87  _size += sizeof(uintptr_t);
     88  if (_size < min_free_size) _size = min_free_size;
     89  return exps_of_two[get_order(_size)] - sizeof(uintptr_t);
     90}
     91
    8292inline size_t HeapAllocator::get_size (void* _ptr)
    8393{
  • to-imperative/trunk/libp++/pxx_malloc_allocator.hh

    r273 r275  
    5555  // Resize memory block at _ptr to _size bytes
    5656  inline void* reallocate (void* _ptr, size_t _size) throw (SysError) ;
     57  //
     58  // Returns (if possible) a real size (probably larger then given)
     59  // of memory block to be allocated
     60  inline size_t get_real_size (size_t _size) ;
    5761};
    5862
  • to-imperative/trunk/libp++/pxx_malloc_allocator.ih

    r263 r275  
    6363}
    6464
     65//
     66// Returns (if possible) a real size (probably larger then given)
     67// of memory block to be allocated
     68inline size_t MallocAllocator::get_real_size (size_t _size)
     69{
     70  return size;
     71}
     72
    6573}
    6674
Note: See TracChangeset for help on using the changeset viewer.