]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | // -*- mode: c++; c-basic-offset: 4 -*- |
2 | /* | |
3 | * This file is part of the KDE libraries | |
4 | * Copyright (C) 2005 Apple Computer, Inc. | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Library General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2 of the License, or (at your option) any later version. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Library General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Library General Public License | |
17 | * along with this library; see the file COPYING.LIB. If not, write to | |
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
19 | * Boston, MA 02110-1301, USA. | |
20 | * | |
21 | */ | |
22 | ||
23 | #ifndef WTF_FastMalloc_h | |
24 | #define WTF_FastMalloc_h | |
25 | ||
26 | #include "Platform.h" | |
27 | #include <stdlib.h> | |
28 | #include <new> | |
29 | ||
30 | namespace WTF { | |
31 | ||
32 | void *fastMalloc(size_t n); | |
33 | void *fastZeroedMalloc(size_t n); | |
34 | void *fastCalloc(size_t n_elements, size_t element_size); | |
35 | void fastFree(void* p); | |
36 | void *fastRealloc(void* p, size_t n); | |
37 | ||
38 | #ifndef NDEBUG | |
39 | void fastMallocForbid(); | |
40 | void fastMallocAllow(); | |
41 | #endif | |
42 | ||
43 | } // namespace WTF | |
44 | ||
45 | using WTF::fastMalloc; | |
46 | using WTF::fastZeroedMalloc; | |
47 | using WTF::fastCalloc; | |
48 | using WTF::fastRealloc; | |
49 | using WTF::fastFree; | |
50 | ||
51 | #ifndef NDEBUG | |
52 | using WTF::fastMallocForbid; | |
53 | using WTF::fastMallocAllow; | |
54 | #endif | |
55 | ||
56 | #if COMPILER(GCC) && PLATFORM(DARWIN) | |
57 | #define WTF_PRIVATE_INLINE __private_extern__ inline __attribute__((always_inline)) | |
58 | #elif COMPILER(GCC) | |
59 | #define WTF_PRIVATE_INLINE inline __attribute__((always_inline)) | |
60 | #elif COMPILER(MSVC) | |
61 | #define WTF_PRIVATE_INLINE __forceinline | |
62 | #else | |
63 | #define WTF_PRIVATE_INLINE inline | |
64 | #endif | |
65 | ||
66 | #ifndef _CRTDBG_MAP_ALLOC | |
67 | ||
68 | #if !defined(USE_SYSTEM_MALLOC) || !(USE_SYSTEM_MALLOC) | |
69 | WTF_PRIVATE_INLINE void* operator new(size_t s) { return fastMalloc(s); } | |
70 | WTF_PRIVATE_INLINE void operator delete(void* p) { fastFree(p); } | |
71 | WTF_PRIVATE_INLINE void* operator new[](size_t s) { return fastMalloc(s); } | |
72 | WTF_PRIVATE_INLINE void operator delete[](void* p) { fastFree(p); } | |
73 | ||
74 | extern "C" { | |
75 | void releaseFastMallocFreeMemory(); | |
76 | } | |
77 | #endif | |
78 | ||
79 | #endif // _CRTDBG_MAP_ALLOC | |
80 | ||
81 | #endif /* WTF_FastMalloc_h */ |