[vmkit-commits] [vmkit] r103379 - /vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun May 9 08:34:33 PDT 2010


Author: geoffray
Date: Sun May  9 10:34:32 2010
New Revision: 103379

URL: http://llvm.org/viewvc/llvm-project?rev=103379&view=rev
Log:
Do a new instead of alloca for creating array names, which can be arbitarly long.


Modified:
    vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp

Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=103379&r1=103378&r2=103379&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Sun May  9 10:34:32 2010
@@ -671,7 +671,8 @@
   if (I == End) {
     const UTF8* internalName = readerConstructUTF8(name->elements, name->size);
     res = new(allocator, "Class") UserClass(this, internalName, bytes);
-    classes->map.insert(std::make_pair(internalName, res));
+    bool success = classes->map.insert(std::make_pair(internalName, res)).second;
+    assert(success && "Could not add class in map");
   } else {
     res = ((UserClass*)(I->second));
   }
@@ -988,7 +989,7 @@
   uint32 pos = steps;
   bool isTab = (className->elements[0] == I_TAB ? true : false);
   uint32 n = steps + len + (isTab ? 0 : 2);
-  uint16* buf = (uint16*)alloca(n * sizeof(uint16));
+  uint16* buf = new uint16[n];
     
   for (uint32 i = 0; i < steps; i++) {
     buf[i] = I_TAB;
@@ -1007,7 +1008,9 @@
     buf[n - 1] = I_END_REF;
   }
 
-  return readerConstructUTF8(buf, n);
+  const UTF8* res = readerConstructUTF8(buf, n);
+  delete[] buf;
+  return res;
 }
 
 intptr_t JnjvmClassLoader::loadInLib(const char* buf, bool& j3) {





More information about the vmkit-commits mailing list