Lines 42-57
Link Here
|
42 |
|
42 |
|
43 |
#if defined(MOZ_ALWAYS_INLINE_EVEN_DEBUG) |
43 |
#if defined(MOZ_ALWAYS_INLINE_EVEN_DEBUG) |
44 |
# define MOZALLOC_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG |
44 |
# define MOZALLOC_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG |
45 |
#elif defined(HAVE_FORCEINLINE) |
45 |
#elif defined(HAVE_FORCEINLINE) |
46 |
# define MOZALLOC_INLINE __forceinline |
46 |
# define MOZALLOC_INLINE __forceinline |
47 |
#else |
47 |
#else |
48 |
# define MOZALLOC_INLINE inline |
48 |
# define MOZALLOC_INLINE inline |
49 |
#endif |
49 |
#endif |
|
|
50 |
#define MOZALLOC_INLINE |
50 |
|
51 |
|
51 |
/* Workaround build problem with Sun Studio 12 */ |
52 |
/* Workaround build problem with Sun Studio 12 */ |
52 |
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) |
53 |
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) |
53 |
# undef NS_WARN_UNUSED_RESULT |
54 |
# undef NS_WARN_UNUSED_RESULT |
54 |
# define NS_WARN_UNUSED_RESULT |
55 |
# define NS_WARN_UNUSED_RESULT |
55 |
# undef NS_ATTR_MALLOC |
56 |
# undef NS_ATTR_MALLOC |
56 |
# define NS_ATTR_MALLOC |
57 |
# define NS_ATTR_MALLOC |
57 |
#endif |
58 |
#endif |
Lines 190-252
MOZALLOC_EXPORT void* moz_valloc(size_t
Link Here
|
190 |
#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS |
191 |
#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS |
191 |
#else |
192 |
#else |
192 |
#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS throw() |
193 |
#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS throw() |
193 |
#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS throw(std::bad_alloc) |
194 |
#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS throw(std::bad_alloc) |
194 |
#endif |
195 |
#endif |
195 |
|
196 |
|
196 |
#define MOZALLOC_THROW_BAD_ALLOC MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS |
197 |
#define MOZALLOC_THROW_BAD_ALLOC MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS |
197 |
|
198 |
|
198 |
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE |
199 |
MOZALLOC_EXPORT_NEW |
199 |
void* operator new(size_t size) MOZALLOC_THROW_BAD_ALLOC |
200 |
void* operator new(size_t size) MOZALLOC_THROW_BAD_ALLOC; |
200 |
{ |
|
|
201 |
return moz_xmalloc(size); |
202 |
} |
203 |
|
201 |
|
204 |
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE |
202 |
MOZALLOC_EXPORT_NEW |
205 |
void* operator new(size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
203 |
void* operator new(size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
206 |
{ |
|
|
207 |
return moz_malloc(size); |
208 |
} |
209 |
|
204 |
|
210 |
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE |
205 |
MOZALLOC_EXPORT_NEW |
211 |
void* operator new[](size_t size) MOZALLOC_THROW_BAD_ALLOC |
206 |
void* operator new[](size_t size) MOZALLOC_THROW_BAD_ALLOC; |
212 |
{ |
|
|
213 |
return moz_xmalloc(size); |
214 |
} |
215 |
|
207 |
|
216 |
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE |
208 |
MOZALLOC_EXPORT_NEW |
217 |
void* operator new[](size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
209 |
void* operator new[](size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
218 |
{ |
|
|
219 |
return moz_malloc(size); |
220 |
} |
221 |
|
210 |
|
222 |
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE |
211 |
MOZALLOC_EXPORT_NEW |
223 |
void operator delete(void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
212 |
void operator delete(void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
224 |
{ |
|
|
225 |
return moz_free(ptr); |
226 |
} |
227 |
|
213 |
|
228 |
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE |
214 |
MOZALLOC_EXPORT_NEW |
229 |
void operator delete(void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
215 |
void operator delete(void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
230 |
{ |
|
|
231 |
return moz_free(ptr); |
232 |
} |
233 |
|
216 |
|
234 |
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE |
217 |
MOZALLOC_EXPORT_NEW |
235 |
void operator delete[](void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
218 |
void operator delete[](void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
236 |
{ |
|
|
237 |
return moz_free(ptr); |
238 |
} |
239 |
|
219 |
|
240 |
MOZALLOC_EXPORT_NEW MOZALLOC_INLINE |
220 |
MOZALLOC_EXPORT_NEW |
241 |
void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
221 |
void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
242 |
{ |
|
|
243 |
return moz_free(ptr); |
244 |
} |
245 |
|
222 |
|
246 |
|
223 |
|
247 |
/* |
224 |
/* |
248 |
* We also add a new allocator variant: "fallible operator new." |
225 |
* We also add a new allocator variant: "fallible operator new." |
249 |
* Unlike libmozalloc's implementations of the standard nofail |
226 |
* Unlike libmozalloc's implementations of the standard nofail |
250 |
* allocators, this allocator is allowed to return NULL. It can be used |
227 |
* allocators, this allocator is allowed to return NULL. It can be used |
251 |
* as follows |
228 |
* as follows |
252 |
* |
229 |
* |
Lines 258-293
void operator delete[](void* ptr, const
Link Here
|
258 |
* delete'd by any of |
235 |
* delete'd by any of |
259 |
* |
236 |
* |
260 |
* (1) the matching "fallible" operator delete below |
237 |
* (1) the matching "fallible" operator delete below |
261 |
* (2) the matching infallible operator delete above |
238 |
* (2) the matching infallible operator delete above |
262 |
* (3) the matching system |operator delete(void*, std::nothrow)| |
239 |
* (3) the matching system |operator delete(void*, std::nothrow)| |
263 |
* (4) the matching system |operator delete(void*) throw(std::bad_alloc)| |
240 |
* (4) the matching system |operator delete(void*) throw(std::bad_alloc)| |
264 |
*/ |
241 |
*/ |
265 |
|
242 |
|
266 |
MOZALLOC_INLINE |
|
|
267 |
void* operator new(size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
268 |
{ |
269 |
return moz_malloc(size); |
270 |
} |
271 |
|
243 |
|
272 |
MOZALLOC_INLINE |
244 |
void* operator new(size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
273 |
void* operator new[](size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
|
|
274 |
{ |
275 |
return moz_malloc(size); |
276 |
} |
277 |
|
245 |
|
278 |
MOZALLOC_INLINE |
|
|
279 |
void operator delete(void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
280 |
{ |
281 |
moz_free(ptr); |
282 |
} |
283 |
|
246 |
|
284 |
MOZALLOC_INLINE |
247 |
void* operator new[](size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
285 |
void operator delete[](void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS |
248 |
|
286 |
{ |
249 |
|
287 |
moz_free(ptr); |
250 |
void operator delete(void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
288 |
} |
251 |
|
|
|
252 |
|
253 |
void operator delete[](void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS; |
289 |
|
254 |
|
290 |
#endif /* ifdef __cplusplus */ |
255 |
#endif /* ifdef __cplusplus */ |
291 |
|
256 |
|
292 |
|
257 |
|
293 |
#endif /* ifndef mozilla_mozalloc_h */ |
258 |
#endif /* ifndef mozilla_mozalloc_h */ |