aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2010-04-03 01:09:47 +0000
committerJohnny Chen <johnny.chen@apple.com>2010-04-03 01:09:47 +0000
commitb35ae7f7d6fb6bbeb08246922760f0f55b7a8b5d (patch)
tree3c2c6a3b42414380fe626f19603630f50a4e5912 /lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp
parentd3a5fa8e96e146087dc2259ce14ccee8c5a4fb61 (diff)
downloadexternal_llvm-b35ae7f7d6fb6bbeb08246922760f0f55b7a8b5d.zip
external_llvm-b35ae7f7d6fb6bbeb08246922760f0f55b7a8b5d.tar.gz
external_llvm-b35ae7f7d6fb6bbeb08246922760f0f55b7a8b5d.tar.bz2
Register ARMAlgorithm::DoCleanup() to be called on exit to free the memory
occuplied by the cached ARMAlgorithm objects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp')
-rw-r--r--lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp b/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp
index 41c8c22..9f41455 100644
--- a/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp
+++ b/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp
@@ -3130,6 +3130,13 @@ static const DisassembleFP FuncPtrs[] = {
/// Algorithms - Algorithms stores a map from Format to ARMAlgorithm*.
static std::vector<ARMAlgorithm*> Algorithms;
+/// DoCleanup - Do cleanup of Algorithms upon exit.
+void ARMAlgorithm::DoCleanup() {
+ for (unsigned i = 0; i < array_lengthof(FuncPtrs); ++i)
+ if (Algorithms[i])
+ delete Algorithms[i];
+}
+
/// GetInstance - GetInstance returns an instance of ARMAlgorithm given the
/// encoding Format. API clients should not free up the returned instance.
ARMAlgorithm *ARMAlgorithm::GetInstance(ARMFormat Format) {
@@ -3141,11 +3148,13 @@ ARMAlgorithm *ARMAlgorithm::GetInstance(ARMFormat Format) {
Algorithms[i] = new ARMAlgorithm(FuncPtrs[i]);
else
Algorithms[i] = NULL;
+
+ // Register cleanup routine.
+ atexit(DoCleanup);
}
return Algorithms[Format];
}
-
/// BuildIt - BuildIt performs the build step for this ARM Basic MC Builder.
/// The general idea is to set the Opcode for the MCInst, followed by adding
/// the appropriate MCOperands to the MCInst. ARM Basic MC Builder delegates