| 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 SkTDArray_DEFINED | 10 #ifndef SkTDArray_DEFINED |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 #ifdef SK_DEBUG | 341 #ifdef SK_DEBUG |
| 342 void validate() const { | 342 void validate() const { |
| 343 SkASSERT((fReserve == 0 && fArray == NULL) || | 343 SkASSERT((fReserve == 0 && fArray == NULL) || |
| 344 (fReserve > 0 && fArray != NULL)); | 344 (fReserve > 0 && fArray != NULL)); |
| 345 SkASSERT(fCount <= fReserve); | 345 SkASSERT(fCount <= fReserve); |
| 346 SkASSERT(fData == (ArrayT*)fArray); | 346 SkASSERT(fData == (ArrayT*)fArray); |
| 347 } | 347 } |
| 348 #endif | 348 #endif |
| 349 | 349 |
| 350 void shrinkToFit() { |
| 351 fReserve = fCount; |
| 352 fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T)); |
| 353 } |
| 354 |
| 350 private: | 355 private: |
| 351 #ifdef SK_DEBUG | 356 #ifdef SK_DEBUG |
| 352 enum { | 357 enum { |
| 353 kDebugArraySize = 16 | 358 kDebugArraySize = 16 |
| 354 }; | 359 }; |
| 355 typedef T ArrayT[kDebugArraySize]; | 360 typedef T ArrayT[kDebugArraySize]; |
| 356 ArrayT* fData; | 361 ArrayT* fData; |
| 357 #endif | 362 #endif |
| 358 T* fArray; | 363 T* fArray; |
| 359 int fReserve; | 364 int fReserve; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 380 fReserve = count + 4; | 385 fReserve = count + 4; |
| 381 fReserve += fReserve / 4; | 386 fReserve += fReserve / 4; |
| 382 fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T)); | 387 fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T)); |
| 383 #ifdef SK_DEBUG | 388 #ifdef SK_DEBUG |
| 384 fData = (ArrayT*)fArray; | 389 fData = (ArrayT*)fArray; |
| 385 #endif | 390 #endif |
| 386 } | 391 } |
| 387 }; | 392 }; |
| 388 | 393 |
| 389 #endif | 394 #endif |
| OLD | NEW |