summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/Event_Service/Memory_Pools.i
blob: 3f6e3b262231c27f071d6ce5ed9c0f323c1c83d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* -*- C++ -*- */
// $Id$

ACE_INLINE void *
ACE_ES_Memory_Pools::new_Event_Container (void)
{
  return Event_Container_->malloc (sizeof (ACE_ES_Event_Container));
}

ACE_INLINE void
ACE_ES_Memory_Pools::delete_Event_Container (void *mem)
{
  Event_Container_->free (mem);
}

ACE_INLINE void *
ACE_ES_Memory_Pools::new_Dispatch_Request (void)
{
  return Dispatch_Request_->malloc (sizeof (ACE_ES_Dispatch_Request));
}

ACE_INLINE void
ACE_ES_Memory_Pools::delete_Dispatch_Request (void *mem)
{
  Dispatch_Request_->free (mem);
}

#define USE_MEM_POOLS 1

ACE_INLINE void *
ACE_ES_Memory_Pools::new_Event (size_t len)
{
#if USE_MEM_POOLS
  const u_int ev_size = sizeof (RtecEventComm::Event);
  const u_int size = (ev_size % ACE_MALLOC_ALIGN) ?
      ((ev_size / ACE_MALLOC_ALIGN) + 1) * ACE_MALLOC_ALIGN : ev_size;

  char *const addr = (char *) Event_->malloc (len * size);
#else
  char *const addr = new char[len * sizeof (ACE_ES_Event)];
#endif

  return addr;
}

ACE_INLINE void
ACE_ES_Memory_Pools::delete_Event (void *mem)
{
#if USE_MEM_POOLS
  Event_->free (mem);
#else
  delete [] mem;
#endif
}