| # Gaudi Framework, version v22r0 |

Home |  | Generated: 9 Feb 2011

# IgHookTraceAlloc Class Reference

`#include <IgHook_IgHookTrace.h>`

List of all members.

## Public Member Functions
| IgHookTraceAlloc (void)
void * | allocate (size_t bytes)
## Private Attributes
void * | m_pool
size_t | m_left

## Detailed Description

Definition at line 15 of file IgHook_IgHookTrace.h.

## Constructor & Destructor Documentation

IgHookTraceAlloc::IgHookTraceAlloc | ( | void |  | ) |

Definition at line 99 of file IgHook_IgHookTrace.cpp.

    00100     : m_pool (0),
    00101       m_left (0)
    00102 {}

## Member Function Documentation

void * IgHookTraceAlloc::allocate | ( | size_t | bytes | ) |

Definition at line 105 of file IgHook_IgHookTrace.cpp.

    00106 {
    00107     // The reason for the existence of this class is to allocate
    00108     // memory directly using mmap() so we don't create calls to
    00109     // malloc() and friends.  This is for two reasons: it must be
    00110     // possible to use this in asynchronous signal handlers, and
    00111     // calling malloc() in those is a really bad idea; and this is
    00112     // meant to be used by profiling code and it's nicer to not
    00113     // allocate memory in ways tracked by the profiler.
    00114     if (m_left < bytes)
    00115     {
    00116         size_t psize = getpagesize ();
    00117         size_t hunk = psize * 20;
    00118         if (hunk < bytes) hunk = (hunk + psize - 1) & ~(psize-1);
    00119         void *addr = mmap (0, hunk, PROT_READ | PROT_WRITE,
    00120                            MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
    00121         if (addr == MAP_FAILED)
    00122             return 0;
    00123
    00124         m_pool = addr;
    00125         m_left = hunk;
    00126     }
    00127
    00128     void *ptr = m_pool;
    00129     m_pool = (char *) m_pool + bytes;
    00130     m_left -= bytes;
    00131     return ptr;
    00132 }

## Member Data Documentation

size_t IgHookTraceAlloc::m_left`[private]`

Definition at line 24 of file IgHook_IgHookTrace.h.

void* IgHookTraceAlloc::m_pool`[private]`

Definition at line 23 of file IgHook_IgHookTrace.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r0/GaudiProfiling/src/component/IgHook_IgHookTrace.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r0/GaudiProfiling/src/component/IgHook_IgHookTrace.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines