Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkTemplates_DEFINED | 10 #ifndef SkTemplates_DEFINED |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 | 289 |
| 290 T& operator[](int index) { | 290 T& operator[](int index) { |
| 291 return fPtr[index]; | 291 return fPtr[index]; |
| 292 } | 292 } |
| 293 | 293 |
| 294 const T& operator[](int index) const { | 294 const T& operator[](int index) const { |
| 295 return fPtr[index]; | 295 return fPtr[index]; |
| 296 } | 296 } |
| 297 | 297 |
| 298 /** | 298 /** |
| 299 * Releases the block back to the heap | |
| 300 */ | |
| 301 void free() { | |
|
reed1
2015/12/10 16:04:12
seemes like a fine method/name. Does SkAutoMalloc
scroggo
2015/12/10 16:26:45
Yes. That supports my desire to make reset() retur
| |
| 302 this->reset(0); | |
| 303 } | |
| 304 | |
| 305 /** | |
| 299 * Transfer ownership of the ptr to the caller, setting the internal | 306 * Transfer ownership of the ptr to the caller, setting the internal |
| 300 * pointer to NULL. Note that this differs from get(), which also returns | 307 * pointer to NULL. Note that this differs from get(), which also returns |
| 301 * the pointer, but it does not transfer ownership. | 308 * the pointer, but it does not transfer ownership. |
| 302 */ | 309 */ |
| 303 T* detach() { | 310 T* detach() { |
| 304 T* ptr = fPtr; | 311 T* ptr = fPtr; |
| 305 fPtr = NULL; | 312 fPtr = NULL; |
| 306 return ptr; | 313 return ptr; |
| 307 } | 314 } |
| 308 | 315 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 * Returns void* because this object does not initialize the | 449 * Returns void* because this object does not initialize the |
| 443 * memory. Use placement new for types that require a cons. | 450 * memory. Use placement new for types that require a cons. |
| 444 */ | 451 */ |
| 445 void* get() { return fStorage.get(); } | 452 void* get() { return fStorage.get(); } |
| 446 const void* get() const { return fStorage.get(); } | 453 const void* get() const { return fStorage.get(); } |
| 447 private: | 454 private: |
| 448 SkAlignedSStorage<sizeof(T)*N> fStorage; | 455 SkAlignedSStorage<sizeof(T)*N> fStorage; |
| 449 }; | 456 }; |
| 450 | 457 |
| 451 #endif | 458 #endif |
| OLD | NEW |