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

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

Issue 1504313005: fix a couple flaky nonnull attribute ubsan warnings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | src/core/SkRecordDraw.cpp » ('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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 /** Much like calloc: returns a pointer to at least size zero bytes, or NULL on failure. 93 /** Much like calloc: returns a pointer to at least size zero bytes, or NULL on failure.
94 */ 94 */
95 SK_API extern void* sk_calloc(size_t size); 95 SK_API extern void* sk_calloc(size_t size);
96 96
97 /** Same as sk_calloc, but throws an exception instead of returning NULL on fail ure. 97 /** Same as sk_calloc, but throws an exception instead of returning NULL on fail ure.
98 */ 98 */
99 SK_API extern void* sk_calloc_throw(size_t size); 99 SK_API extern void* sk_calloc_throw(size_t size);
100 100
101 // bzero is safer than memset, but we can't rely on it, so... sk_bzero() 101 // bzero is safer than memset, but we can't rely on it, so... sk_bzero()
102 static inline void sk_bzero(void* buffer, size_t size) { 102 static inline void sk_bzero(void* buffer, size_t size) {
103 memset(buffer, 0, size); 103 // Please c.f. sk_careful_memcpy. It's undefined behavior to call memset(nu ll, 0, 0).
104 if (size) {
105 memset(buffer, 0, size);
106 }
104 } 107 }
105 108
106 /////////////////////////////////////////////////////////////////////////////// 109 ///////////////////////////////////////////////////////////////////////////////
107 110
108 #ifdef override_GLOBAL_NEW 111 #ifdef override_GLOBAL_NEW
109 #include <new> 112 #include <new>
110 113
111 inline void* operator new(size_t size) { 114 inline void* operator new(size_t size) {
112 return sk_malloc_throw(size); 115 return sk_malloc_throw(size);
113 } 116 }
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 private: 693 private:
691 void* fPtr; 694 void* fPtr;
692 size_t fSize; // can be larger than the requested size (see kReuse) 695 size_t fSize; // can be larger than the requested size (see kReuse)
693 uint32_t fStorage[(kSize + 3) >> 2]; 696 uint32_t fStorage[(kSize + 3) >> 2];
694 }; 697 };
695 // Can't guard the constructor because it's a template class. 698 // Can't guard the constructor because it's a template class.
696 699
697 #endif /* C++ */ 700 #endif /* C++ */
698 701
699 #endif 702 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698