Rev | Line | |
---|
[176] | 1 | #ifndef _LOCKMALLOCHEAP_H_ |
---|
| 2 | #define _LOCKMALLOCHEAP_H_ |
---|
| 3 | |
---|
| 4 | #include "hldefines.h" |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | // Just lock malloc (unlike LockedHeap, which locks both malloc and |
---|
| 8 | // free). Meant to be combined with something like RedirectFree, which will |
---|
| 9 | // implement free. |
---|
| 10 | |
---|
| 11 | namespace Hoard { |
---|
| 12 | |
---|
| 13 | template <typename Heap> |
---|
| 14 | class LockMallocHeap : public Heap { |
---|
| 15 | public: |
---|
| 16 | MALLOC_FUNCTION INLINE void * malloc (size_t sz) { |
---|
| 17 | HL::Guard<Heap> l (*this); |
---|
| 18 | return Heap::malloc (sz); |
---|
| 19 | } |
---|
| 20 | }; |
---|
| 21 | |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.