SectionData.cpp revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
1//===- SectionData.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/LD/SectionData.h>
10
11#include <mcld/LD/LDSection.h>
12#include <mcld/Support/GCFactory.h>
13
14#include <llvm/Support/ManagedStatic.h>
15
16using namespace mcld;
17
18typedef GCFactory<SectionData, MCLD_SECTIONS_PER_INPUT> SectDataFactory;
19
20static llvm::ManagedStatic<SectDataFactory> g_SectDataFactory;
21
22//===----------------------------------------------------------------------===//
23// SectionData
24//===----------------------------------------------------------------------===//
25SectionData::SectionData()
26  : m_pSection(NULL) {
27}
28
29SectionData::SectionData(LDSection &pSection)
30  : m_pSection(&pSection) {
31}
32
33SectionData* SectionData::Create(LDSection& pSection)
34{
35  SectionData* result = g_SectDataFactory->allocate();
36  new (result) SectionData(pSection);
37  return result;
38}
39
40void SectionData::Destroy(SectionData*& pSection)
41{
42  pSection->~SectionData();
43  g_SectDataFactory->deallocate(pSection);
44  pSection = NULL;
45}
46
47