| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 other.checked_ = true; | 29 other.checked_ = true; |
| 30 } | 30 } |
| 31 | 31 |
| 32 CheckReturnValue& operator=(const CheckReturnValue& other) { | 32 CheckReturnValue& operator=(const CheckReturnValue& other) { |
| 33 if (this != &other) { | 33 if (this != &other) { |
| 34 DCHECK(checked_); | 34 DCHECK(checked_); |
| 35 value_ = other.value_; | 35 value_ = other.value_; |
| 36 checked_ = other.checked_; | 36 checked_ = other.checked_; |
| 37 other.checked_ = true; | 37 other.checked_ = true; |
| 38 } | 38 } |
| 39 return *this; |
| 39 } | 40 } |
| 40 | 41 |
| 41 ~CheckReturnValue() { | 42 ~CheckReturnValue() { |
| 42 DCHECK(checked_); | 43 DCHECK(checked_); |
| 43 } | 44 } |
| 44 | 45 |
| 45 operator const T&() const { | 46 operator const T&() const { |
| 46 checked_ = true; | 47 checked_ = true; |
| 47 return value_; | 48 return value_; |
| 48 } | 49 } |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 protected: | 498 protected: |
| 498 T* buffer_; | 499 T* buffer_; |
| 499 size_t size_; // how much of the buffer we're using. | 500 size_t size_; // how much of the buffer we're using. |
| 500 size_t alloc_size_; // how much space we have allocated. | 501 size_t alloc_size_; // how much space we have allocated. |
| 501 Allocator alloc_; | 502 Allocator alloc_; |
| 502 }; | 503 }; |
| 503 | 504 |
| 504 } // namespace courgette | 505 } // namespace courgette |
| 505 | 506 |
| 506 #endif // COURGETTE_MEMORY_ALLOCATOR_H_ | 507 #endif // COURGETTE_MEMORY_ALLOCATOR_H_ |
| OLD | NEW |