Gaudi Framework, version v23r0

Home   Generated: Mon Jan 30 2012
Public Member Functions | Private Attributes

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 16 of file IgHook_IgHookTrace.h.


Constructor & Destructor Documentation

IgHookTraceAlloc::IgHookTraceAlloc ( void   )

Definition at line 99 of file IgHook_IgHookTrace.cpp.

    : m_pool (0),
      m_left (0)
{}

Member Function Documentation

void * IgHookTraceAlloc::allocate ( size_t  bytes )

Definition at line 105 of file IgHook_IgHookTrace.cpp.

{
    // The reason for the existence of this class is to allocate
    // memory directly using mmap() so we don't create calls to
    // malloc() and friends.  This is for two reasons: it must be
    // possible to use this in asynchronous signal handlers, and
    // calling malloc() in those is a really bad idea; and this is
    // meant to be used by profiling code and it's nicer to not
    // allocate memory in ways tracked by the profiler.
    if (m_left < bytes)
    {
        size_t psize = getpagesize ();
        size_t hunk = psize * 20;
        if (hunk < bytes) hunk = (hunk + psize - 1) & ~(psize-1);
        void *addr = mmap (0, hunk, PROT_READ | PROT_WRITE,
                           MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        if (addr == MAP_FAILED)
            return 0;

        m_pool = addr;
        m_left = hunk;
    }

    void *ptr = m_pool;
    m_pool = (char *) m_pool + bytes;
    m_left -= bytes;
    return ptr;
}

Member Data Documentation

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Jan 30 2012 13:53:17 for Gaudi Framework, version v23r0 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004