OLD | NEW |
1 // Copyright (c) 2005, 2007, Google Inc. | 1 // Copyright (c) 2005, 2007, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserv
ed. | 3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserv
ed. |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 void* fastZeroedMalloc(size_t n) | 177 void* fastZeroedMalloc(size_t n) |
178 { | 178 { |
179 void* result = fastMalloc(n); | 179 void* result = fastMalloc(n); |
180 memset(result, 0, n); | 180 memset(result, 0, n); |
181 return result; | 181 return result; |
182 } | 182 } |
183 | 183 |
184 char* fastStrDup(const char* src) | 184 char* fastStrDup(const char* src) |
185 { | 185 { |
186 int len = strlen(src) + 1; | 186 size_t len = strlen(src) + 1; |
187 char* dup = static_cast<char*>(fastMalloc(len)); | 187 char* dup = static_cast<char*>(fastMalloc(len)); |
188 | 188 memcpy(dup, src, len); |
189 if (dup) | |
190 memcpy(dup, src, len); | |
191 | |
192 return dup; | 189 return dup; |
193 } | 190 } |
194 | 191 |
195 TryMallocReturnValue tryFastZeroedMalloc(size_t n) | 192 TryMallocReturnValue tryFastZeroedMalloc(size_t n) |
196 { | 193 { |
197 void* result; | 194 void* result; |
198 if (!tryFastMalloc(n).getValue(result)) | 195 if (!tryFastMalloc(n).getValue(result)) |
199 return 0; | 196 return 0; |
200 memset(result, 0, n); | 197 memset(result, 0, n); |
201 return result; | 198 return result; |
202 } | 199 } |
203 | 200 |
204 } // namespace WTF | 201 } // namespace WTF |
(...skipping 4415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4620 { | 4617 { |
4621 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Cen
tral_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator); | 4618 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Cen
tral_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator); |
4622 } | 4619 } |
4623 | 4620 |
4624 #endif // OS(DARWIN) | 4621 #endif // OS(DARWIN) |
4625 | 4622 |
4626 } // namespace WTF | 4623 } // namespace WTF |
4627 #endif // WTF_CHANGES | 4624 #endif // WTF_CHANGES |
4628 | 4625 |
4629 #endif // FORCE_SYSTEM_MALLOC | 4626 #endif // FORCE_SYSTEM_MALLOC |
OLD | NEW |