Home | History | Annotate | Download | only in Support
      1 //===- MemoryRegion.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/MemoryRegion.h>
     10 
     11 using namespace mcld;
     12 
     13 //==========================
     14 // MemoryRegion
     15 MemoryRegion::MemoryRegion(MemoryArea::Space *pParentSpace,
     16                            const MemoryRegion::Address pVMAStart,
     17                            size_t pSize)
     18   : m_pParentSpace(pParentSpace), m_VMAStart(pVMAStart), m_Length(pSize) {
     19   m_pParentSpace->region_num++;
     20 }
     21 
     22 MemoryRegion::~MemoryRegion()
     23 {
     24   drift();
     25 }
     26 
     27 void MemoryRegion::drift()
     28 {
     29   if (NULL == m_pParentSpace)
     30     return;
     31   m_pParentSpace->region_num--;
     32   m_pParentSpace = NULL;
     33 }
     34 
     35