Reviewers: plesner,
Description:
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.
Please review this at http://codereview.chromium.org/155917
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/compilation-cache.cc
M src/string-stream.h
M src/string-stream.cc
Index: src/string-stream.h
===================================================================
--- src/string-stream.h (revision 2518)
+++ src/string-stream.h (working copy)
@@ -57,11 +57,10 @@
// 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);
Index: src/compilation-cache.cc
===================================================================
--- src/compilation-cache.cc (revision 2518)
+++ src/compilation-cache.cc (working copy)
@@ -63,6 +63,8 @@
tables_ = NewArray<Object*>(generations);
}
+ ~CompilationSubCache() { DeleteArray(tables_); }
+
// Get the compilation cache tables for a specific generation.
Handle<CompilationCacheTable> GetTable(int generation);
Index: src/string-stream.cc
===================================================================
--- src/string-stream.cc (revision 2518)
+++ src/string-stream.cc (working copy)
@@ -44,12 +44,6 @@
}
-NoAllocationStringAllocator::NoAllocationStringAllocator(unsigned bytes) {
- size_ = bytes;
- space_ = NewArray<char>(bytes);
-}
-
-
NoAllocationStringAllocator::NoAllocationStringAllocator(char* memory,
unsigned size) {
size_ = size;
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---