Home | History | Annotate | Download | only in Support
      1 //===- RegionFactory.cpp --------------------------------------------------===//
      2 //
      3 //                     The MCLinker Project
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 #include "mcld/Support/RegionFactory.h"
     10 #include "mcld/Support/MemoryArea.h"
     11 
     12 using namespace mcld;
     13 
     14 //==========================
     15 // RegionFactory
     16 RegionFactory::RegionFactory(size_t pNum)
     17   : GCFactory<MemoryRegion, 0>(pNum) {
     18 }
     19 
     20 RegionFactory::~RegionFactory()
     21 {
     22 }
     23 
     24 MemoryRegion* RegionFactory::produce(MemoryArea::Space* pSpace,
     25                                      const sys::fs::detail::Address pVMAStart,
     26                                      size_t pSize)
     27 {
     28   MemoryRegion* result = Alloc::allocate();
     29   new (result) MemoryRegion(pSpace, pVMAStart, pSize);
     30   return result;
     31 }
     32 
     33 void RegionFactory::destruct(MemoryRegion* pRegion)
     34 {
     35   pRegion->drift();
     36   destroy(pRegion);
     37   deallocate(pRegion);
     38 }
     39 
     40