Valgrind cleanliness, part 5: Delete extensions on exit.

This fixes 4 leaks, returning 196 bytes of lost memory.

Review URL: https://chromiumcodereview.appspot.com/9864034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11184 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c12a9ed6
......@@ -512,6 +512,16 @@ void RegisteredExtension::Register(RegisteredExtension* that) {
}
void RegisteredExtension::UnregisterAll() {
RegisteredExtension* re = first_extension_;
while (re != NULL) {
RegisteredExtension* next = re->next();
delete re;
re = next;
}
}
void RegisterExtension(Extension* that) {
RegisteredExtension* extension = new RegisteredExtension(that);
RegisteredExtension::Register(extension);
......
......@@ -146,6 +146,7 @@ class RegisteredExtension {
public:
explicit RegisteredExtension(Extension* extension);
static void Register(RegisteredExtension* that);
static void UnregisterAll();
Extension* extension() { return extension_; }
RegisteredExtension* next() { return next_; }
RegisteredExtension* next_auto() { return next_auto_; }
......
......@@ -133,11 +133,8 @@ v8::Handle<v8::Value> ExternalizeStringExtension::IsAscii(
void ExternalizeStringExtension::Register() {
static ExternalizeStringExtension* externalize_extension = NULL;
if (externalize_extension == NULL)
externalize_extension = new ExternalizeStringExtension;
static v8::DeclareExtension externalize_extension_declaration(
externalize_extension);
static ExternalizeStringExtension externalize_extension;
static v8::DeclareExtension declaration(&externalize_extension);
}
} } // namespace v8::internal
......@@ -46,9 +46,8 @@ v8::Handle<v8::Value> GCExtension::GC(const v8::Arguments& args) {
void GCExtension::Register() {
static GCExtension* gc_extension = NULL;
if (gc_extension == NULL) gc_extension = new GCExtension();
static v8::DeclareExtension gc_extension_declaration(gc_extension);
static GCExtension gc_extension;
static v8::DeclareExtension declaration(&gc_extension);
}
} } // namespace v8::internal
......@@ -106,6 +106,7 @@ void V8::TearDown() {
ElementsAccessor::TearDown();
LOperand::TearDownCaches();
RegisteredExtension::UnregisterAll();
isolate->TearDown();
delete isolate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment