// // Copyright (C) 2000-2002 Andrey Slepuhin // // libp++ is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // libp++ is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with libp++; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // $Source$ // $Revision$ // $Date$ // Author: Andrey Slepuhin #ifndef __pxx_malloc_allocator_ih__ #define __pxx_malloc_allocator_ih__ #include "pxx_malloc_allocator.hh" #include "pxx_allocator.ih" #include "pxx_sys_error.ih" namespace pxx { inline MallocAllocator::MallocAllocator () {} inline MallocAllocator::~MallocAllocator () {} // // Allocate memory block of _size bytes inline void* MallocAllocator::allocate (size_t _size) throw (SysError) { void* p = malloc(_size); if (p != null) return p; else throw SysError(ENOMEM); } // // Free memory block at _ptr inline void MallocAllocator::deallocate (void* _ptr) { free(_ptr); } // // Resize memory block at _ptr to _size bytes inline void* MallocAllocator::reallocate (void* _ptr, size_t _size) throw (SysError) { void* p = realloc(_ptr, _size); if (p != null) return p; else throw SysError(ENOMEM); } // // Returns (if possible) a real size (probably larger then given) // of memory block to be allocated inline size_t MallocAllocator::get_real_size (size_t _size) const { return _size; } // // Returns (if possible) the start address of allocated block containing a // pointer, otherwise returns null inline void* MallocAllocator::get_block (void*) { return null; } // // The same as previous, but using block size inline void* MallocAllocator::get_block (void*, size_t) { return null; } inline bool MallocAllocator::is_dyn_addr (void*) { return false; } } #endif // __pxx_malloc_allocator_ih__