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

Side by Side Diff: include/core/SkTemplates.h

Issue 356913003: Don't set SK_MALLOC_TEMP in SkAutoTMalloc. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 */ 323 */
324 template <typename T> class SkAutoTMalloc : SkNoncopyable { 324 template <typename T> class SkAutoTMalloc : SkNoncopyable {
325 public: 325 public:
326 /** Takes ownership of the ptr. The ptr must be a value which can be passed to sk_free. */ 326 /** Takes ownership of the ptr. The ptr must be a value which can be passed to sk_free. */
327 explicit SkAutoTMalloc(T* ptr = NULL) { 327 explicit SkAutoTMalloc(T* ptr = NULL) {
328 fPtr = ptr; 328 fPtr = ptr;
329 } 329 }
330 330
331 /** Allocates space for 'count' Ts. */ 331 /** Allocates space for 'count' Ts. */
332 explicit SkAutoTMalloc(size_t count) { 332 explicit SkAutoTMalloc(size_t count) {
333 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLO C_TEMP); 333 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW);
334 } 334 }
335 335
336 ~SkAutoTMalloc() { 336 ~SkAutoTMalloc() {
337 sk_free(fPtr); 337 sk_free(fPtr);
338 } 338 }
339 339
340 /** Resize the memory area pointed to by the current ptr preserving contents . */ 340 /** Resize the memory area pointed to by the current ptr preserving contents . */
341 void realloc(size_t count) { 341 void realloc(size_t count) {
342 fPtr = reinterpret_cast<T*>(sk_realloc_throw(fPtr, count * sizeof(T))); 342 fPtr = reinterpret_cast<T*>(sk_realloc_throw(fPtr, count * sizeof(T)));
343 } 343 }
344 344
345 /** Resize the memory area pointed to by the current ptr without preserving contents. */ 345 /** Resize the memory area pointed to by the current ptr without preserving contents. */
346 void reset(size_t count) { 346 void reset(size_t count) {
347 sk_free(fPtr); 347 sk_free(fPtr);
348 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLO C_TEMP); 348 fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW);
349 } 349 }
350 350
351 T* get() const { return fPtr; } 351 T* get() const { return fPtr; }
352 352
353 operator T*() { 353 operator T*() {
354 return fPtr; 354 return fPtr;
355 } 355 }
356 356
357 operator const T*() const { 357 operator const T*() const {
358 return fPtr; 358 return fPtr;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 /** 470 /**
471 * Returns void* because this object does not initialize the 471 * Returns void* because this object does not initialize the
472 * memory. Use placement new for types that require a cons. 472 * memory. Use placement new for types that require a cons.
473 */ 473 */
474 void* get() { return fStorage.get(); } 474 void* get() { return fStorage.get(); }
475 private: 475 private:
476 SkAlignedSStorage<sizeof(T)*N> fStorage; 476 SkAlignedSStorage<sizeof(T)*N> fStorage;
477 }; 477 };
478 478
479 #endif 479 #endif
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