OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 class AllStatic { | 74 class AllStatic { |
75 #ifdef DEBUG | 75 #ifdef DEBUG |
76 public: | 76 public: |
77 void* operator new(size_t size); | 77 void* operator new(size_t size); |
78 void operator delete(void* p); | 78 void operator delete(void* p); |
79 #endif | 79 #endif |
80 }; | 80 }; |
81 | 81 |
82 | 82 |
83 template <typename T> | 83 template <typename T> |
84 static T* NewArray(int size) { | 84 T* NewArray(int size) { |
85 T* result = new T[size]; | 85 T* result = new T[size]; |
86 if (result == NULL) Malloced::FatalProcessOutOfMemory(); | 86 if (result == NULL) Malloced::FatalProcessOutOfMemory(); |
87 return result; | 87 return result; |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 template <typename T> | 91 template <typename T> |
92 static void DeleteArray(T* array) { | 92 void DeleteArray(T* array) { |
93 delete[] array; | 93 delete[] array; |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 // The normal strdup functions use malloc. These versions of StrDup | 97 // The normal strdup functions use malloc. These versions of StrDup |
98 // and StrNDup uses new and calls the FatalProcessOutOfMemory handler | 98 // and StrNDup uses new and calls the FatalProcessOutOfMemory handler |
99 // if allocation fails. | 99 // if allocation fails. |
100 char* StrDup(const char* str); | 100 char* StrDup(const char* str); |
101 char* StrNDup(const char* str, int n); | 101 char* StrNDup(const char* str, int n); |
102 | 102 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 friend class Isolate; | 135 friend class Isolate; |
136 | 136 |
137 DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); | 137 DISALLOW_IMPLICIT_CONSTRUCTORS(PreallocatedStorage); |
138 }; | 138 }; |
139 | 139 |
140 | 140 |
141 } } // namespace v8::internal | 141 } } // namespace v8::internal |
142 | 142 |
143 #endif // V8_ALLOCATION_H_ | 143 #endif // V8_ALLOCATION_H_ |
OLD | NEW |