Changeset 46999 in webkit for trunk/JavaScriptCore/wtf/FastMalloc.h
- Timestamp:
- Aug 10, 2009, 12:42:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/FastMalloc.h
r46180 r46999 1 1 /* 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 29 29 30 30 // These functions call CRASH() if an allocation fails. 31 void* fastMalloc(size_t n);32 void* fastZeroedMalloc(size_t n);33 void* fastCalloc(size_t n _elements, size_t element_size);34 void* fastRealloc(void* p, size_t n);31 void* fastMalloc(size_t); 32 void* fastZeroedMalloc(size_t); 33 void* fastCalloc(size_t numElements, size_t elementSize); 34 void* fastRealloc(void*, size_t); 35 35 36 // These functions return NULLif an allocation fails.37 void* tryFastMalloc(size_t n);38 void* tryFastZeroedMalloc(size_t n);39 void* tryFastCalloc(size_t n _elements, size_t element_size);40 void* tryFastRealloc(void* p, size_t n);36 // These functions return 0 if an allocation fails. 37 void* tryFastMalloc(size_t); 38 void* tryFastZeroedMalloc(size_t); 39 void* tryFastCalloc(size_t numElements, size_t elementSize); 40 void* tryFastRealloc(void*, size_t); 41 41 42 void fastFree(void* p);42 void fastFree(void*); 43 43 44 44 #ifndef NDEBUG … … 173 173 #endif 174 174 175 #if ndef _CRTDBG_MAP_ALLOC175 #if !defined(_CRTDBG_MAP_ALLOC) && !(defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC) 176 176 177 #if !defined(USE_SYSTEM_MALLOC) || !(USE_SYSTEM_MALLOC) 178 WTF_PRIVATE_INLINE void* operator new(size_t s) { return fastMalloc(s); } 177 // The nothrow functions here are actually not all that helpful, because fastMalloc will 178 // call CRASH() rather than returning 0, and returning 0 is what nothrow is all about. 179 // But since WebKit code never uses exceptions or nothrow at all, this is probably OK. 180 // Long term we will adopt FastAllocBase.h everywhere, and and replace this with 181 // debug-only code to make sure we don't use the system malloc via the default operator 182 // new by accident. 183 184 WTF_PRIVATE_INLINE void* operator new(size_t size) { return fastMalloc(s); } 185 WTF_PRIVATE_INLINE void* operator new(size_t size, const std::nothrow_t&) throw() { return fastMalloc(size); } 179 186 WTF_PRIVATE_INLINE void operator delete(void* p) { fastFree(p); } 180 WTF_PRIVATE_INLINE void* operator new[](size_t s) { return fastMalloc(s); } 187 WTF_PRIVATE_INLINE void* operator new[](size_t size) { return fastMalloc(size); } 188 WTF_PRIVATE_INLINE void* operator new[](size_t size, const std::nothrow_t&) throw() { return fastMalloc(size); } 181 189 WTF_PRIVATE_INLINE void operator delete[](void* p) { fastFree(p); } 182 190 183 #if PLATFORM(WINCE)184 WTF_PRIVATE_INLINE void* operator new(size_t s, const std::nothrow_t&) throw() { return fastMalloc(s); }185 WTF_PRIVATE_INLINE void operator delete(void* p, const std::nothrow_t&) throw() { fastFree(p); }186 WTF_PRIVATE_INLINE void* operator new[](size_t s, const std::nothrow_t&) throw() { return fastMalloc(s); }187 WTF_PRIVATE_INLINE void operator delete[](void* p, const std::nothrow_t&) throw() { fastFree(p); }188 #endif189 191 #endif 190 192 191 #endif // _CRTDBG_MAP_ALLOC192 193 193 #endif /* WTF_FastMalloc_h */
Note:
See TracChangeset
for help on using the changeset viewer.