Index: src/v8threads.cc |
diff --git a/src/v8threads.cc b/src/v8threads.cc |
index fd8d5364011cdee45c196cd58550fa31313cb9d7..32ea5e197c483ff0b018e3b9a68a223f5b1432ce 100644 |
--- a/src/v8threads.cc |
+++ b/src/v8threads.cc |
@@ -1,4 +1,4 @@ |
-// Copyright 2008 the V8 project authors. All rights reserved. |
+// Copyright 2012 the V8 project authors. All rights reserved. |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
// met: |
@@ -238,12 +238,18 @@ static int ArchiveSpacePerThread() { |
ThreadState::ThreadState(ThreadManager* thread_manager) |
: id_(ThreadId::Invalid()), |
terminate_on_restore_(false), |
+ data_(NULL), |
next_(this), |
previous_(this), |
thread_manager_(thread_manager) { |
} |
+ThreadState::~ThreadState() { |
+ DeleteArray<char>(data_); |
+} |
+ |
+ |
void ThreadState::AllocateSpace() { |
data_ = NewArray<char>(ArchiveSpacePerThread()); |
} |
@@ -306,8 +312,19 @@ ThreadManager::ThreadManager() |
ThreadManager::~ThreadManager() { |
delete mutex_; |
- delete free_anchor_; |
- delete in_use_anchor_; |
+ DeleteThreadStateList(free_anchor_); |
+ DeleteThreadStateList(in_use_anchor_); |
+} |
+ |
+ |
+void ThreadManager::DeleteThreadStateList(ThreadState* anchor) { |
+ // The list starts and ends with the anchor. |
+ for (ThreadState* current = anchor->next_; current != anchor;) { |
+ ThreadState* next = current->next_; |
+ delete current; |
+ current = next; |
+ } |
+ delete anchor; |
} |