source:
proiecte/swift/trunk/lib/hoard-371/src/heaplayers/tryheap.h
@
176
Last change on this file since 176 was 176, checked in by , 14 years ago | |
---|---|
File size: 382 bytes |
Rev | Line | |
---|---|---|
[176] | 1 | #ifndef _TRYHEAP_H_ |
2 | #define _TRYHEAP_H_ | |
3 | ||
4 | template <class Heap1, class Heap2> | |
5 | class TryHeap : public Heap2 { | |
6 | public: | |
7 | TryHeap (void) | |
8 | {} | |
9 | ||
10 | inline void * malloc (size_t sz) { | |
11 | void * ptr = heap1.malloc (sz); | |
12 | if (ptr == NULL) | |
13 | ptr = Heap2::malloc (sz); | |
14 | return ptr; | |
15 | } | |
16 | ||
17 | inline void free (void * ptr) { | |
18 | heap1.free (ptr); | |
19 | } | |
20 | ||
21 | private: | |
22 | Heap1 heap1; | |
23 | }; | |
24 | ||
25 | ||
26 | #endif |
Note: See TracBrowser
for help on using the repository browser.