OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_ZONE_H_ | 5 #ifndef VM_ZONE_H_ |
6 #define VM_ZONE_H_ | 6 #define VM_ZONE_H_ |
7 | 7 |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/handles.h" | 10 #include "vm/handles.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 | 112 |
113 // Delete all objects and free all memory allocated in the zone. | 113 // Delete all objects and free all memory allocated in the zone. |
114 void DeleteAll(); | 114 void DeleteAll(); |
115 | 115 |
116 // Does not actually free any memory. Enables templated containers like | 116 // Does not actually free any memory. Enables templated containers like |
117 // BaseGrowableArray to use different allocators. | 117 // BaseGrowableArray to use different allocators. |
118 template <class ElementType> | 118 template <class ElementType> |
119 void Free(ElementType* old_array, intptr_t len) { | 119 void Free(ElementType* old_array, intptr_t len) { |
120 #ifdef DEBUG | 120 #ifdef DEBUG |
121 memset(old_array, kZapUninitializedByte, len * sizeof(ElementType)); | 121 if (len > 0) { |
| 122 memset(old_array, kZapUninitializedByte, len * sizeof(ElementType)); |
| 123 } |
122 #endif | 124 #endif |
123 } | 125 } |
124 | 126 |
125 #if defined(DEBUG) | 127 #if defined(DEBUG) |
126 // Dump the current allocated sizes in the zone object. | 128 // Dump the current allocated sizes in the zone object. |
127 void DumpZoneSizes(); | 129 void DumpZoneSizes(); |
128 #endif | 130 #endif |
129 | 131 |
130 // Overflow check (FATAL) for array length. | 132 // Overflow check (FATAL) for array length. |
131 template <class ElementType> | 133 template <class ElementType> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 memmove(reinterpret_cast<void*>(new_data), | 285 memmove(reinterpret_cast<void*>(new_data), |
284 reinterpret_cast<void*>(old_data), | 286 reinterpret_cast<void*>(old_data), |
285 old_len * kElementSize); | 287 old_len * kElementSize); |
286 } | 288 } |
287 return new_data; | 289 return new_data; |
288 } | 290 } |
289 | 291 |
290 } // namespace dart | 292 } // namespace dart |
291 | 293 |
292 #endif // VM_ZONE_H_ | 294 #endif // VM_ZONE_H_ |
OLD | NEW |