Fix the last memory leak demonstrated by the test program in
authorerik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 28 Sep 2009 13:53:03 +0000 (13:53 +0000)
committererik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 28 Sep 2009 13:53:03 +0000 (13:53 +0000)
http://code.google.com/p/v8/issues/detail?id=444
Review URL: http://codereview.chromium.org/243027

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2978 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/api.h
src/list.h

index 4e792b72f044b973abec68a947e23ee0fc852d23..1221f352cc678a35def37a2316c09a13814b3ace 100644 (file)
--- a/src/api.h
+++ b/src/api.h
@@ -369,6 +369,9 @@ class HandleScopeImplementer {
     ASSERT(blocks_.length() == 0);
     ASSERT(entered_contexts_.length() == 0);
     ASSERT(saved_contexts_.length() == 0);
+    blocks_.Free();
+    entered_contexts_.Free();
+    saved_contexts_.Free();
     if (spare_ != NULL) {
       DeleteArray(spare_);
       spare_ = NULL;
index dd7ea1c9cab9f3e44deb1c6003b62093ab031ce4..25211d9a7b52b1d3ecf7192bb6d42893b0040f14 100644 (file)
@@ -51,6 +51,13 @@ class List {
   INLINE(explicit List(int capacity)) { Initialize(capacity); }
   INLINE(~List()) { DeleteData(data_); }
 
+  // Deallocates memory used by the list and leaves the list in a consistent
+  // empty state.
+  void Free() {
+    DeleteData(data_);
+    Initialize(0);
+  }
+
   INLINE(void* operator new(size_t size)) { return P::New(size); }
   INLINE(void operator delete(void* p, size_t)) { return P::Delete(p); }