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

Side by Side Diff: Source/wtf/Deque.h

Issue 23531010: Ensure that Vector destruction always clears the buffer pointer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 | « no previous file | Source/wtf/Vector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 15 matching lines...) Expand all
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #ifndef WTF_Deque_h 30 #ifndef WTF_Deque_h
31 #define WTF_Deque_h 31 #define WTF_Deque_h
32 32
33 // FIXME: Could move what Vector and Deque share into a separate file. 33 // FIXME: Could move what Vector and Deque share into a separate file.
34 // Deque doesn't actually use Vector. 34 // Deque doesn't actually use Vector.
35 35
36 #include <iterator>
37 #include "wtf/PassTraits.h" 36 #include "wtf/PassTraits.h"
38 #include "wtf/Vector.h" 37 #include "wtf/Vector.h"
38 #include <iterator>
39 39
40 namespace WTF { 40 namespace WTF {
41 41
42 template<typename T, size_t inlineCapacity> class DequeIteratorBase; 42 template<typename T, size_t inlineCapacity> class DequeIteratorBase;
43 template<typename T, size_t inlineCapacity> class DequeIterator; 43 template<typename T, size_t inlineCapacity> class DequeIterator;
44 template<typename T, size_t inlineCapacity> class DequeConstIterator; 44 template<typename T, size_t inlineCapacity> class DequeConstIterator;
45 45
46 template<typename T, size_t inlineCapacity = 0> 46 template<typename T, size_t inlineCapacity = 0>
47 class Deque { 47 class Deque {
48 WTF_MAKE_FAST_ALLOCATED; 48 WTF_MAKE_FAST_ALLOCATED;
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 template<typename T, size_t inlineCapacity> 343 template<typename T, size_t inlineCapacity>
344 inline void Deque<T, inlineCapacity>::clear() 344 inline void Deque<T, inlineCapacity>::clear()
345 { 345 {
346 checkValidity(); 346 checkValidity();
347 invalidateIterators(); 347 invalidateIterators();
348 destroyAll(); 348 destroyAll();
349 m_start = 0; 349 m_start = 0;
350 m_end = 0; 350 m_end = 0;
351 m_buffer.deallocateBuffer(m_buffer.buffer()); 351 m_buffer.deallocateBuffer(m_buffer.buffer());
352 m_buffer.clearBufferPointer();
352 checkValidity(); 353 checkValidity();
353 } 354 }
354 355
355 template<typename T, size_t inlineCapacity> 356 template<typename T, size_t inlineCapacity>
356 template<typename Predicate> 357 template<typename Predicate>
357 inline DequeIterator<T, inlineCapacity> Deque<T, inlineCapacity>::findIf(Pre dicate& predicate) 358 inline DequeIterator<T, inlineCapacity> Deque<T, inlineCapacity>::findIf(Pre dicate& predicate)
358 { 359 {
359 iterator end_iterator = end(); 360 iterator end_iterator = end();
360 for (iterator it = begin(); it != end_iterator; ++it) { 361 for (iterator it = begin(); it != end_iterator; ++it) {
361 if (predicate(*it)) 362 if (predicate(*it))
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 if (!m_index) 639 if (!m_index)
639 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1] ; 640 return &m_deque->m_buffer.buffer()[m_deque->m_buffer.capacity() - 1] ;
640 return &m_deque->m_buffer.buffer()[m_index - 1]; 641 return &m_deque->m_buffer.buffer()[m_index - 1];
641 } 642 }
642 643
643 } // namespace WTF 644 } // namespace WTF
644 645
645 using WTF::Deque; 646 using WTF::Deque;
646 647
647 #endif // WTF_Deque_h 648 #endif // WTF_Deque_h
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/Vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698