Changeset 263


Ignore:
Timestamp:
Dec 6, 2002, 11:43:51 AM (18 years ago)
Author:
pooh
Message:
  • Methods are inlined. Exception specifications added.
Location:
to-imperative/trunk/libp++
Files:
2 edited

Legend:

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

    r258 r263  
    3737  //
    3838  // Constructor
    39   MallocAllocator () ;
     39  inline MallocAllocator () ;
    4040  //
    4141  // Destructor
    42   ~MallocAllocator () ;
     42  inline ~MallocAllocator () ;
    4343  //
    4444  // Allocate memory block of _size bytes
    45   void* allocate (size_t _size) = 0 ;
     45  inline void* allocate (size_t _size) throw (SysError) ;
    4646  //
    4747  // Free memory block at _ptr
    48   void deallocate (void* _ptr) = 0 ;
     48  inline void deallocate (void* _ptr) ;
    4949  //
    5050  // Resize memory block at _ptr to _size bytes
    51   void* reallocate (void* _ptr, size_t _size) = 0 ;
     51  inline void* reallocate (void* _ptr, size_t _size) throw (SysError) ;
    5252};
    5353
  • to-imperative/trunk/libp++/pxx_malloc_allocator.ih

    r258 r263  
    2525
    2626#include "pxx_malloc_allocator.hh"
     27#include "pxx_sys_error.ih"
    2728
    2829namespace pxx
    2930{
    3031
    31 MallocAllocator::MallocAllocator ()
     32inline MallocAllocator::MallocAllocator ()
    3233{}
    3334
    34 MallocAllocator::~MallocAllocator ()
     35inline MallocAllocator::~MallocAllocator ()
    3536{}
    3637
    3738//
    3839// Allocate memory block of _size bytes
    39 void* MallocAllocator::allocate (size_t _size)
     40inline void* MallocAllocator::allocate (size_t _size)
     41  throw (SysError)
    4042{
    41   return malloc(_size);
     43  void* p = malloc(_size);
     44  if (p != null) return p;
     45  else throw SysError(ENOMEM);
    4246}
    4347
    4448//
    4549// Free memory block at _ptr
    46 void MallocAllocator::deallocate (void* _ptr)
     50inline void MallocAllocator::deallocate (void* _ptr)
    4751{
    4852  free(_ptr);
     
    5155//
    5256// Resize memory block at _ptr to _size bytes
    53 void* MallocAllocator::reallocate (void* _ptr, size_t _size)
     57inline void* MallocAllocator::reallocate (void* _ptr, size_t _size)
     58  throw (SysError)
    5459{
    55   return realloc(_ptr, _size);
     60  void* p = realloc(_ptr, _size);
     61  if (p != null) return p;
     62  else throw SysError(ENOMEM);
    5663}
    5764
Note: See TracChangeset for help on using the changeset viewer.