Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/list.h

Issue 243027: Fix the last memory leak demonstrated by the test program in... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 // Forward defined as 45 // Forward defined as
46 // template <typename T, class P = FreeStoreAllocationPolicy> class List; 46 // template <typename T, class P = FreeStoreAllocationPolicy> class List;
47 template <typename T, class P> 47 template <typename T, class P>
48 class List { 48 class List {
49 public: 49 public:
50 50
51 INLINE(explicit List(int capacity)) { Initialize(capacity); } 51 INLINE(explicit List(int capacity)) { Initialize(capacity); }
52 INLINE(~List()) { DeleteData(data_); } 52 INLINE(~List()) { DeleteData(data_); }
53 53
54 // Deallocates memory used by the list and leaves the list in a consistent
55 // empty state.
56 void Free() {
57 DeleteData(data_);
58 Initialize(0);
59 }
60
54 INLINE(void* operator new(size_t size)) { return P::New(size); } 61 INLINE(void* operator new(size_t size)) { return P::New(size); }
55 INLINE(void operator delete(void* p, size_t)) { return P::Delete(p); } 62 INLINE(void operator delete(void* p, size_t)) { return P::Delete(p); }
56 63
57 // Returns a reference to the element at index i. This reference is 64 // Returns a reference to the element at index i. This reference is
58 // not safe to use after operations that can change the list's 65 // not safe to use after operations that can change the list's
59 // backing store (eg, Add). 66 // backing store (eg, Add).
60 inline T& operator[](int i) const { 67 inline T& operator[](int i) const {
61 ASSERT(0 <= i && i < length_); 68 ASSERT(0 <= i && i < length_);
62 return data_[i]; 69 return data_[i];
63 } 70 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 146
140 // Add() is inlined, ResizeAdd() called by Add() is inlined except for 147 // Add() is inlined, ResizeAdd() called by Add() is inlined except for
141 // Lists of FrameElements, and ResizeAddInternal() is inlined in ResizeAdd(). 148 // Lists of FrameElements, and ResizeAddInternal() is inlined in ResizeAdd().
142 template <> 149 template <>
143 void List<FrameElement, 150 void List<FrameElement,
144 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element); 151 FreeStoreAllocationPolicy>::ResizeAdd(const FrameElement& element);
145 152
146 } } // namespace v8::internal 153 } } // namespace v8::internal
147 154
148 #endif // V8_LIST_H_ 155 #endif // V8_LIST_H_
OLDNEW
« no previous file with comments | « src/api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698