From 4ab2d2009e4a16d1a5104047e1e2cdbbf2cb9b1a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Apr 2007 17:20:52 +0000 Subject: [PATCH] fix a memory leak git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36396 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/Analyzer.cpp | 18 +++++++++--------- lib/Bytecode/Reader/Reader.cpp | 11 ++++++----- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/Bytecode/Reader/Analyzer.cpp b/lib/Bytecode/Reader/Analyzer.cpp index 2a752d769cc..dde73dfb1a8 100644 --- a/lib/Bytecode/Reader/Analyzer.cpp +++ b/lib/Bytecode/Reader/Analyzer.cpp @@ -165,7 +165,7 @@ public: << " Linkage=" << Linkage << " Visibility="<< Visibility << " Type="; - WriteTypeSymbolic(*os, ElemType, M); + //WriteTypeSymbolic(*os, ElemType, M); *os << " Slot=" << SlotNum << " InitSlot=" << initSlot << "\n"; } @@ -187,7 +187,7 @@ public: bca.numTypes++; if (os) { *os << " Type: "; - WriteTypeSymbolic(*os,Ty,M); + //WriteTypeSymbolic(*os,Ty,M); *os << "\n"; } } @@ -199,7 +199,7 @@ public: bca.numValues++; if (os) { *os << " Function Decl: "; - WriteTypeSymbolic(*os,Func->getType(),M); + //WriteTypeSymbolic(*os,Func->getType(),M); *os <<", Linkage=" << Func->getLinkage(); *os <<", Visibility=" << Func->getVisibility(); *os << "\n"; @@ -276,13 +276,13 @@ public: << " Linkage: " << Func->getLinkage() << "\n" << " Visibility: " << Func->getVisibility() << "\n" << " Type: "; - WriteTypeSymbolic(*os,Func->getType(),M); + //WriteTypeSymbolic(*os,Func->getType(),M); *os << "\n"; } currFunc = &bca.FunctionInfo[Func]; std::ostringstream tmp; - WriteTypeSymbolic(tmp,Func->getType(),M); + //WriteTypeSymbolic(tmp,Func->getType(),M); currFunc->description = tmp.str(); currFunc->name = Func->getName(); currFunc->byteSize = Size; @@ -388,7 +388,7 @@ public: Constant* ArrayVal ) { if (os) { *os << " ARRAY: "; - WriteTypeSymbolic(*os,AT,M); + //WriteTypeSymbolic(*os,AT,M); *os << " TypeSlot=" << TypeSlot << "\n"; for (unsigned i = 0; i != NumElts; ++i) { *os << " #" << i; @@ -411,7 +411,7 @@ public: { if (os) { *os << " STRUC: "; - WriteTypeSymbolic(*os,ST,M); + //WriteTypeSymbolic(*os,ST,M); *os << "\n"; for ( unsigned i = 0; i != NumElts; ++i) { *os << " #" << i << " "; Elements[i]->print(*os); @@ -433,7 +433,7 @@ public: { if (os) { *os << " PACKD: "; - WriteTypeSymbolic(*os,PT,M); + //WriteTypeSymbolic(*os,PT,M); *os << " TypeSlot=" << TypeSlot << "\n"; for ( unsigned i = 0; i != NumElts; ++i ) { *os << " #" << i; @@ -453,7 +453,7 @@ public: unsigned Slot, GlobalValue* GV ) { if (os) { *os << " PNTR: "; - WriteTypeSymbolic(*os,PT,M); + //WriteTypeSymbolic(*os,PT,M); *os << " Slot=" << Slot << " GlobalValue="; GV->print(*os); *os << "\n"; diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 98ed57ea6f4..ee6d9e6208c 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -1299,11 +1299,12 @@ Value *BytecodeReader::ParseConstantPoolValue(unsigned TypeID) { Result = ConstantInt::get(IT, Val); if (Handler) Handler->handleConstantValue(Result); } else { - uint32_t numWords = read_vbr_uint(); - uint64_t *data = new uint64_t[numWords]; - for (uint32_t i = 0; i < numWords; ++i) - data[i] = read_vbr_uint64(); - Result = ConstantInt::get(APInt(IT->getBitWidth(), numWords, data)); + uint32_t NumWords = read_vbr_uint(); + SmallVector Words; + Words.resize(NumWords); + for (uint32_t i = 0; i < NumWords; ++i) + Words[i] = read_vbr_uint64(); + Result = ConstantInt::get(APInt(IT->getBitWidth(), NumWords, &Words[0])); if (Handler) Handler->handleConstantValue(Result); } break; -- 2.34.1