OSDN Git Service

fix a memory leak
authorChris Lattner <sabre@nondot.org>
Tue, 24 Apr 2007 17:20:52 +0000 (17:20 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 24 Apr 2007 17:20:52 +0000 (17:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36396 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Reader/Analyzer.cpp
lib/Bytecode/Reader/Reader.cpp

index 2a752d7..dde73df 100644 (file)
@@ -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";
index 98ed57e..ee6d9e6 100644 (file)
@@ -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<uint64_t, 8> 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;