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

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

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 years, 3 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 | « include/core/SkTemplates.h ('k') | include/gpu/GrClipData.h » ('j') | 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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 SkTypes_DEFINED 8 #ifndef SkTypes_DEFINED
9 #define SkTypes_DEFINED 9 #define SkTypes_DEFINED
10 10
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 * block. 532 * block.
533 */ 533 */
534 kReuse_OnShrink 534 kReuse_OnShrink
535 }; 535 };
536 536
537 /** 537 /**
538 * Reallocates the block to a new size. The ptr may or may not change. 538 * Reallocates the block to a new size. The ptr may or may not change.
539 */ 539 */
540 void* reset(size_t size, OnShrink shrink = kAlloc_OnShrink, bool* didChange Alloc = NULL) { 540 void* reset(size_t size, OnShrink shrink = kAlloc_OnShrink, bool* didChange Alloc = NULL) {
541 if (size == fSize || (kReuse_OnShrink == shrink && size < fSize)) { 541 if (size == fSize || (kReuse_OnShrink == shrink && size < fSize)) {
542 if (NULL != didChangeAlloc) { 542 if (didChangeAlloc) {
543 *didChangeAlloc = false; 543 *didChangeAlloc = false;
544 } 544 }
545 return fPtr; 545 return fPtr;
546 } 546 }
547 547
548 sk_free(fPtr); 548 sk_free(fPtr);
549 fPtr = size ? sk_malloc_throw(size) : NULL; 549 fPtr = size ? sk_malloc_throw(size) : NULL;
550 fSize = size; 550 fSize = size;
551 if (NULL != didChangeAlloc) { 551 if (didChangeAlloc) {
552 *didChangeAlloc = true; 552 *didChangeAlloc = true;
553 } 553 }
554 554
555 return fPtr; 555 return fPtr;
556 } 556 }
557 557
558 /** 558 /**
559 * Releases the block back to the heap 559 * Releases the block back to the heap
560 */ 560 */
561 void free() { 561 void free() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 * Return a new block of the requested size, freeing (as necessary) any 636 * Return a new block of the requested size, freeing (as necessary) any
637 * previously allocated block. As with the constructor, if size <= kSize 637 * previously allocated block. As with the constructor, if size <= kSize
638 * then the return block may be allocated locally, rather than from the 638 * then the return block may be allocated locally, rather than from the
639 * heap. 639 * heap.
640 */ 640 */
641 void* reset(size_t size, 641 void* reset(size_t size,
642 SkAutoMalloc::OnShrink shrink = SkAutoMalloc::kAlloc_OnShrink, 642 SkAutoMalloc::OnShrink shrink = SkAutoMalloc::kAlloc_OnShrink,
643 bool* didChangeAlloc = NULL) { 643 bool* didChangeAlloc = NULL) {
644 size = (size < kSize) ? kSize : size; 644 size = (size < kSize) ? kSize : size;
645 bool alloc = size != fSize && (SkAutoMalloc::kAlloc_OnShrink == shrink | | size > fSize); 645 bool alloc = size != fSize && (SkAutoMalloc::kAlloc_OnShrink == shrink | | size > fSize);
646 if (NULL != didChangeAlloc) { 646 if (didChangeAlloc) {
647 *didChangeAlloc = alloc; 647 *didChangeAlloc = alloc;
648 } 648 }
649 if (alloc) { 649 if (alloc) {
650 if (fPtr != (void*)fStorage) { 650 if (fPtr != (void*)fStorage) {
651 sk_free(fPtr); 651 sk_free(fPtr);
652 } 652 }
653 653
654 if (size == kSize) { 654 if (size == kSize) {
655 SkASSERT(fPtr != fStorage); // otherwise we lied when setting di dChangeAlloc. 655 SkASSERT(fPtr != fStorage); // otherwise we lied when setting di dChangeAlloc.
656 fPtr = fStorage; 656 fPtr = fStorage;
(...skipping 11 matching lines...) Expand all
668 private: 668 private:
669 void* fPtr; 669 void* fPtr;
670 size_t fSize; // can be larger than the requested size (see kReuse) 670 size_t fSize; // can be larger than the requested size (see kReuse)
671 uint32_t fStorage[(kSize + 3) >> 2]; 671 uint32_t fStorage[(kSize + 3) >> 2];
672 }; 672 };
673 // Can't guard the constructor because it's a template class. 673 // Can't guard the constructor because it's a template class.
674 674
675 #endif /* C++ */ 675 #endif /* C++ */
676 676
677 #endif 677 #endif
OLDNEW
« no previous file with comments | « include/core/SkTemplates.h ('k') | include/gpu/GrClipData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698