Fix two deallocation bugs identified by Coverity Prevent.

1. The tables array allocated in the CompilationSubCache constructor
   was never deallocated.  Fixed by adding destructor.

2. The buffer allocated in one of the constructors of the
   NoAllocationStringAllocator was never deallocated.  It seems that
   this class sometimes owns the buffer (if it allocated one itself)
   and sometimes doesn't (if it was passed one).  Simple fix is to
   remove the offending constructor which was never used anyway.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2520 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 21833093
......@@ -63,6 +63,8 @@ class CompilationSubCache {
tables_ = NewArray<Object*>(generations);
}
~CompilationSubCache() { DeleteArray(tables_); }
// Get the compilation cache tables for a specific generation.
Handle<CompilationCacheTable> GetTable(int generation);
......
......@@ -44,12 +44,6 @@ char* HeapStringAllocator::allocate(unsigned bytes) {
}
NoAllocationStringAllocator::NoAllocationStringAllocator(unsigned bytes) {
size_ = bytes;
space_ = NewArray<char>(bytes);
}
NoAllocationStringAllocator::NoAllocationStringAllocator(char* memory,
unsigned size) {
size_ = size;
......
......@@ -57,11 +57,10 @@ class HeapStringAllocator: public StringAllocator {
// Allocator for use when no new c++ heap allocation is allowed.
// Allocates all space up front and does no allocation while building
// message.
// Given a preallocated buffer up front and does no allocation while
// building message.
class NoAllocationStringAllocator: public StringAllocator {
public:
explicit NoAllocationStringAllocator(unsigned bytes);
NoAllocationStringAllocator(char* memory, unsigned size);
char* allocate(unsigned bytes) { return space_; }
char* grow(unsigned* bytes);
......
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