[llvm-commits] [llvm] r40043 - /llvm/trunk/lib/Support/SmallPtrSet.cpp

Owen Anderson resistor at mac.com
Wed Jul 18 23:45:33 PDT 2007


Author: resistor
Date: Thu Jul 19 01:45:33 2007
New Revision: 40043

URL: http://llvm.org/viewvc/llvm-project?rev=40043&view=rev
Log:
Remember to free the heap allocated array if we're not going to use it.

Modified:
    llvm/trunk/lib/Support/SmallPtrSet.cpp

Modified: llvm/trunk/lib/Support/SmallPtrSet.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SmallPtrSet.cpp?rev=40043&r1=40042&r2=40043&view=diff

==============================================================================
--- llvm/trunk/lib/Support/SmallPtrSet.cpp (original)
+++ llvm/trunk/lib/Support/SmallPtrSet.cpp Thu Jul 19 01:45:33 2007
@@ -186,10 +186,12 @@
            "Cannot assign sets with different small sizes");
            
   // If we're becoming small, prepare to insert into our stack space
-  if (RHS.isSmall())
+  if (RHS.isSmall()) {
+    if (!isSmall())
+      free(CurArray);
     CurArray = &SmallArray[0];
   // Otherwise, allocate new heap space (unless we were the same size)
-  else if (CurArraySize != RHS.CurArraySize) {
+  } else if (CurArraySize != RHS.CurArraySize) {
     if (isSmall())
       CurArray = (void**)malloc(sizeof(void*) * (RHS.CurArraySize+1));
     else





More information about the llvm-commits mailing list