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 *fastCalloc(size_t n_elements, size_t element_size);
|
---|
34 | void fastFree(void* p);
|
---|
35 | void *fastRealloc(void* p, size_t n);
|
---|
36 |
|
---|
37 | } // namespace WTF
|
---|
38 |
|
---|
39 | using WTF::fastMalloc;
|
---|
40 | using WTF::fastCalloc;
|
---|
41 | using WTF::fastRealloc;
|
---|
42 | using WTF::fastFree;
|
---|
43 |
|
---|
44 | #if PLATFORM(GCC) && PLATFORM(DARWIN)
|
---|
45 | #define WTF_PRIVATE_INLINE __private_extern__ inline __attribute__((always_inline))
|
---|
46 | #elif PLATFORM(GCC)
|
---|
47 | #define WTF_PRIVATE_INLINE inline __attribute__((always_inline))
|
---|
48 | #else
|
---|
49 | #define WTF_PRIVATE_INLINE inline
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | #ifndef _CRTDBG_MAP_ALLOC
|
---|
53 |
|
---|
54 | WTF_PRIVATE_INLINE void* operator new(size_t s) { return fastMalloc(s); }
|
---|
55 | WTF_PRIVATE_INLINE void operator delete(void* p) { fastFree(p); }
|
---|
56 | WTF_PRIVATE_INLINE void* operator new[](size_t s) { return fastMalloc(s); }
|
---|
57 | WTF_PRIVATE_INLINE void operator delete[](void* p) { fastFree(p); }
|
---|
58 |
|
---|
59 | #endif // _CRTDBG_MAP_ALLOC
|
---|
60 |
|
---|
61 | #endif /* WTF_FastMalloc_h */
|
---|