| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 return result; | 112 return result; |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 template <typename T> | 116 template <typename T> |
| 117 static void DeleteArray(T* array) { | 117 static void DeleteArray(T* array) { |
| 118 delete[] array; | 118 delete[] array; |
| 119 } | 119 } |
| 120 | 120 |
| 121 | 121 |
| 122 // The normal strdup function uses malloc. This version of StrDup | 122 // The normal strdup functions use malloc. These versions of StrDup |
| 123 // uses new and calls the FatalProcessOutOfMemory handler if | 123 // and StrNDup uses new and calls the FatalProcessOutOfMemory handler |
| 124 // allocation fails. | 124 // if allocation fails. |
| 125 char* StrDup(const char* str); | 125 char* StrDup(const char* str); |
| 126 char* StrNDup(const char* str, size_t n); |
| 126 | 127 |
| 127 | 128 |
| 128 // Allocation policy for allocating in the C free store using malloc | 129 // Allocation policy for allocating in the C free store using malloc |
| 129 // and free. Used as the default policy for lists. | 130 // and free. Used as the default policy for lists. |
| 130 class FreeStoreAllocationPolicy { | 131 class FreeStoreAllocationPolicy { |
| 131 public: | 132 public: |
| 132 INLINE(static void* New(size_t size)) { return Malloced::New(size); } | 133 INLINE(static void* New(size_t size)) { return Malloced::New(size); } |
| 133 INLINE(static void Delete(void* p)) { Malloced::Delete(p); } | 134 INLINE(static void Delete(void* p)) { Malloced::Delete(p); } |
| 134 }; | 135 }; |
| 135 | 136 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 158 | 159 |
| 159 void LinkTo(PreallocatedStorage* other); | 160 void LinkTo(PreallocatedStorage* other); |
| 160 void Unlink(); | 161 void Unlink(); |
| 161 DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); | 162 DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 | 165 |
| 165 } } // namespace v8::internal | 166 } } // namespace v8::internal |
| 166 | 167 |
| 167 #endif // V8_ALLOCATION_H_ | 168 #endif // V8_ALLOCATION_H_ |
| OLD | NEW |