OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkTArray_DEFINED | 8 #ifndef SkTArray_DEFINED |
9 #define SkTArray_DEFINED | 9 #define SkTArray_DEFINED |
10 | 10 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 int fAllocCount; | 457 int fAllocCount; |
458 void* fPreAllocMemArray; | 458 void* fPreAllocMemArray; |
459 union { | 459 union { |
460 T* fItemArray; | 460 T* fItemArray; |
461 void* fMemArray; | 461 void* fMemArray; |
462 }; | 462 }; |
463 }; | 463 }; |
464 | 464 |
465 // Use the below macro (SkNEW_APPEND_TO_TARRAY) rather than calling this directl y | 465 // Use the below macro (SkNEW_APPEND_TO_TARRAY) rather than calling this directl y |
466 template <typename T, bool MEM_COPY> | 466 template <typename T, bool MEM_COPY> |
467 void* operator new(size_t, SkTArray<T, MEM_COPY>* array, int atIndex) { | 467 void* operator new(size_t, SkTArray<T, MEM_COPY>* array, int /*atIndex*/) { |
468 // Currently, we only support adding to the end of the array. When the array class itself | 468 // Currently, we only support adding to the end of the array. When the array class itself |
469 // supports random insertion then this should be updated. | 469 // supports random insertion then this should be updated. |
470 // SkASSERT(atIndex >= 0 && atIndex <= array->count()); | 470 // SkASSERT(atIndex >= 0 && atIndex <= array->count()); |
471 SkASSERT(atIndex == array->count()); | |
mtklein
2014/11/14 16:30:15
This seems like a loss. Seems better to SkDEBUGCO
djsollen
2014/11/14 18:55:23
Done.
| |
472 return array->push_back_raw(1); | 471 return array->push_back_raw(1); |
473 } | 472 } |
474 | 473 |
475 // Skia doesn't use C++ exceptions but it may be compiled with them enabled. Hav ing an op delete | 474 // Skia doesn't use C++ exceptions but it may be compiled with them enabled. Hav ing an op delete |
476 // to match the op new silences warnings about missing op delete when a construc tor throws an | 475 // to match the op new silences warnings about missing op delete when a construc tor throws an |
477 // exception. | 476 // exception. |
478 template <typename T, bool MEM_COPY> | 477 template <typename T, bool MEM_COPY> |
479 void operator delete(void*, SkTArray<T, MEM_COPY>* array, int atIndex) { | 478 void operator delete(void*, SkTArray<T, MEM_COPY>* /*array*/, int /*atIndex*/) { |
480 SK_CRASH(); | 479 SK_CRASH(); |
481 } | 480 } |
482 | 481 |
483 // Constructs a new object as the last element of an SkTArray. | 482 // Constructs a new object as the last element of an SkTArray. |
484 #define SkNEW_APPEND_TO_TARRAY(array_ptr, type_name, args) \ | 483 #define SkNEW_APPEND_TO_TARRAY(array_ptr, type_name, args) \ |
485 (new ((array_ptr), (array_ptr)->count()) type_name args) | 484 (new ((array_ptr), (array_ptr)->count()) type_name args) |
486 | 485 |
487 | 486 |
488 /** | 487 /** |
489 * Subclass of SkTArray that contains a preallocated memory block for the array. | 488 * Subclass of SkTArray that contains a preallocated memory block for the array. |
(...skipping 30 matching lines...) Expand all Loading... | |
520 SkSTArray& operator= (const INHERITED& array) { | 519 SkSTArray& operator= (const INHERITED& array) { |
521 INHERITED::operator=(array); | 520 INHERITED::operator=(array); |
522 return *this; | 521 return *this; |
523 } | 522 } |
524 | 523 |
525 private: | 524 private: |
526 SkAlignedSTStorage<N,T> fStorage; | 525 SkAlignedSTStorage<N,T> fStorage; |
527 }; | 526 }; |
528 | 527 |
529 #endif | 528 #endif |
OLD | NEW |