Revision: 3252
Author: [email protected]
Date: Mon Nov 9 05:30:50 2009
Log: Fix small memory leak in new serialization code.
Review URL: http://codereview.chromium.org/371068
http://code.google.com/p/v8/source/detail?r=3252
Modified:
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/bootstrapper.h
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Fri Nov 6 06:06:35 2009
+++ /branches/bleeding_edge/src/bootstrapper.cc Mon Nov 9 05:30:50 2009
@@ -95,23 +95,28 @@
static SourceCodeCache extensions_cache(Script::TYPE_EXTENSION);
// This is for delete, not delete[].
static List<char*>* delete_these_non_arrays_on_tear_down = NULL;
+
+
+NativesExternalStringResource::NativesExternalStringResource(const char*
source)
+ : data_(source), length_(strlen(source)) {
+ if (delete_these_non_arrays_on_tear_down == NULL) {
+ delete_these_non_arrays_on_tear_down = new List<char*>(2);
+ }
+ // The resources are small objects and we only make a fixed number of
+ // them, but let's clean them up on exit for neatness.
+ delete_these_non_arrays_on_tear_down->
+ Add(reinterpret_cast<char*>(this));
+}
Handle<String> Bootstrapper::NativesSourceLookup(int index) {
ASSERT(0 <= index && index < Natives::GetBuiltinsCount());
if (Heap::natives_source_cache()->get(index)->IsUndefined()) {
if (!Snapshot::IsEnabled() || FLAG_new_snapshot) {
- if (delete_these_non_arrays_on_tear_down == NULL) {
- delete_these_non_arrays_on_tear_down = new List<char*>(2);
- }
// We can use external strings for the natives.
NativesExternalStringResource* resource =
new NativesExternalStringResource(
Natives::GetScriptSource(index).start());
- // The resources are small objects and we only make a fixed number of
- // them, but lets clean them up on exit for neatness.
- delete_these_non_arrays_on_tear_down->
- Add(reinterpret_cast<char*>(resource));
Handle<String> source_code =
Factory::NewExternalStringFromAscii(resource);
Heap::natives_source_cache()->set(index, *source_code);
=======================================
--- /branches/bleeding_edge/src/bootstrapper.h Fri Nov 6 05:48:33 2009
+++ /branches/bleeding_edge/src/bootstrapper.h Mon Nov 9 05:30:50 2009
@@ -80,8 +80,7 @@
class NativesExternalStringResource
: public v8::String::ExternalAsciiStringResource {
public:
- explicit NativesExternalStringResource(const char* source)
- : data_(source), length_(strlen(source)) { }
+ explicit NativesExternalStringResource(const char* source);
const char* data() const {
return data_;
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---