OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |