| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Attributes | List of all members
IgHookTraceAlloc Class Reference

`#include <src/component/IgHook_IgHookTrace.h>`

## Public Member Functions
| IgHookTraceAlloc (void)
void * | allocate (size_t bytes)

## Private Attributes
void * | m_pool
size_t | m_left

## Detailed Description

Definition at line 16 of file IgHook_IgHookTrace.h.

## Constructor & Destructor Documentation

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

Definition at line 99 of file IgHook_IgHookTrace.cpp.

100 : m_pool (0),
101 m_left (0)
102 {}
IgHookTraceAlloc::m_left
size_t m_left
Definition: IgHook_IgHookTrace.h:25
IgHookTraceAlloc::m_pool
void * m_pool
Definition: IgHook_IgHookTrace.h:24

## Member Function Documentation

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

Definition at line 105 of file IgHook_IgHookTrace.cpp.

106 {
107 // The reason for the existence of this class is to allocate
108 // memory directly using mmap() so we don't create calls to
109 // malloc() and friends. This is for two reasons: it must be
110 // possible to use this in asynchronous signal handlers, and
111 // calling malloc() in those is a really bad idea; and this is
112 // meant to be used by profiling code and it's nicer to not
113 // allocate memory in ways tracked by the profiler.
114 if (m_left < bytes)
115 {
116 size_t psize = getpagesize ();
117 size_t hunk = psize * 20;
118 if (hunk < bytes) hunk = (hunk + psize - 1) & ~(psize-1);
119 void *addr = mmap (0, hunk, PROT_READ | PROT_WRITE,
120 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
121 if (addr == MAP_FAILED)
122 return 0;
123
124 m_pool = addr;
125 m_left = hunk;
126 }
127
128 void *ptr = m_pool;
129 m_pool = (char *) m_pool + bytes;
130 m_left -= bytes;
131 return ptr;
132 }
IgHookTraceAlloc::m_left
size_t m_left
Definition: IgHook_IgHookTrace.h:25
IgHookTraceAlloc::m_pool
void * m_pool
Definition: IgHook_IgHookTrace.h:24

## Member Data Documentation

size_t IgHookTraceAlloc::m_left
| private

Definition at line 25 of file IgHook_IgHookTrace.h.

void* IgHookTraceAlloc::m_pool
| private

Definition at line 24 of file IgHook_IgHookTrace.h.

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

- GaudiProfiling/src/component/IgHook_IgHookTrace.h
- GaudiProfiling/src/component/IgHook_IgHookTrace.cpp