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

Side by Side Diff: courgette/memory_allocator.h

Issue 2721983002: Stop using undocumented _THROW0() macro (Closed)
Patch Set: Fixing accidental patch set Created 3 years, 9 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
« no previous file with comments | « no previous file | 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COURGETTE_MEMORY_ALLOCATOR_H_ 5 #ifndef COURGETTE_MEMORY_ALLOCATOR_H_
6 #define COURGETTE_MEMORY_ALLOCATOR_H_ 6 #define COURGETTE_MEMORY_ALLOCATOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // (largest at 136MB) 10 allocations just below the threshold and 6362 174 // (largest at 136MB) 10 allocations just below the threshold and 6362
175 // smaller allocations. 175 // smaller allocations.
176 static const size_t kMaxHeapAllocationSize = 1024 * 1024 * 5; 176 static const size_t kMaxHeapAllocationSize = 1024 * 1024 * 5;
177 177
178 template<class OtherT> 178 template<class OtherT>
179 struct rebind { 179 struct rebind {
180 // convert a MemoryAllocator<T> to a MemoryAllocator<OtherT> 180 // convert a MemoryAllocator<T> to a MemoryAllocator<OtherT>
181 typedef MemoryAllocator<OtherT> other; 181 typedef MemoryAllocator<OtherT> other;
182 }; 182 };
183 183
184 MemoryAllocator() _THROW0() { 184 MemoryAllocator() {}
185 }
186 185
187 // We can't use an explicit constructor here, as dictated by our style guide. 186 // We can't use an explicit constructor here, as dictated by our style guide.
188 // The implementation of basic_string in Visual Studio 2010 prevents this. 187 // The implementation of basic_string in Visual Studio 2010 prevents this.
189 MemoryAllocator(const MemoryAllocator<T>& other) _THROW0() { // NOLINT 188 MemoryAllocator(const MemoryAllocator<T>& other) { // NOLINT
190 } 189 }
191 190
192 template<class OtherT> 191 template <class OtherT>
193 MemoryAllocator(const MemoryAllocator<OtherT>& other) _THROW0() { // NOLINT 192 MemoryAllocator(const MemoryAllocator<OtherT>& other) { // NOLINT
194 } 193 }
195 194
196 ~MemoryAllocator() { 195 ~MemoryAllocator() {
197 } 196 }
198 197
199 void deallocate(pointer ptr, size_type size) { 198 void deallocate(pointer ptr, size_type size) {
200 uint8_t* mem = reinterpret_cast<uint8_t*>(ptr); 199 uint8_t* mem = reinterpret_cast<uint8_t*>(ptr);
201 mem -= sizeof(T); 200 mem -= sizeof(T);
202 if (mem[0] == HEAP_ALLOCATION) { 201 if (mem[0] == HEAP_ALLOCATION) {
203 free(mem); 202 free(mem);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 244 }
246 245
247 void construct(pointer ptr, const T& value) { 246 void construct(pointer ptr, const T& value) {
248 ::new(ptr) T(value); 247 ::new(ptr) T(value);
249 } 248 }
250 249
251 void destroy(pointer ptr) { 250 void destroy(pointer ptr) {
252 ptr->~T(); 251 ptr->~T();
253 } 252 }
254 253
255 size_type max_size() const _THROW0() { 254 size_type max_size() const {
256 size_type count = static_cast<size_type>(-1) / sizeof(T); 255 size_type count = static_cast<size_type>(-1) / sizeof(T);
257 return (0 < count ? count : 1); 256 return (0 < count ? count : 1);
258 } 257 }
259 }; 258 };
260 259
261 #else // OS_WIN 260 #else // OS_WIN
262 261
263 // On Mac, Linux, we use a bare bones implementation that only does 262 // On Mac, Linux, we use a bare bones implementation that only does
264 // heap allocations. 263 // heap allocations.
265 template<class T> 264 template<class T>
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 protected: 497 protected:
499 T* buffer_; 498 T* buffer_;
500 size_t size_; // how much of the buffer we're using. 499 size_t size_; // how much of the buffer we're using.
501 size_t alloc_size_; // how much space we have allocated. 500 size_t alloc_size_; // how much space we have allocated.
502 Allocator alloc_; 501 Allocator alloc_;
503 }; 502 };
504 503
505 } // namespace courgette 504 } // namespace courgette
506 505
507 #endif // COURGETTE_MEMORY_ALLOCATOR_H_ 506 #endif // COURGETTE_MEMORY_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698