Commit 526f83d6 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Fix small memory leak in new serialization code.

Review URL: http://codereview.chromium.org/371068

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3252 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cff817d7
......@@ -97,21 +97,26 @@ static SourceCodeCache extensions_cache(Script::TYPE_EXTENSION);
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);
......
......@@ -80,8 +80,7 @@ class Bootstrapper : public AllStatic {
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_;
......
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