summaryrefslogtreecommitdiff
path: root/TAO/tao/Buffer_Allocator_T.cpp
blob: 34a0aa19550ccaa4d9dbe1c4bb584d9fb0bfc176 (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
// $Id$

#ifndef TAO_BUFFER_ALLOCATOR_T_CPP
#define TAO_BUFFER_ALLOCATOR_T_CPP

#include "tao/Buffer_Allocator_T.h"
#include "ace/Global_Macros.h"

namespace TAO
{
  template <typename handler_type, typename alloc_type>
  TAO_Buffer_Allocator<handler_type, alloc_type>::TAO_Buffer_Allocator (alloc_type *allocator) :
    allocator_(allocator)
  {
  }

  template <typename handler_type, typename alloc_type>
  handler_type*
  TAO_Buffer_Allocator<handler_type, alloc_type>::allocate (void)
  {
    handler_type* myvalue = 0;
    ACE_NEW_MALLOC_RETURN (myvalue,
                           static_cast <handler_type*>(
                               allocator_->malloc (sizeof (handler_type))),
                           handler_type (), 0);

    return myvalue;
  }

  template <typename handler_type, typename alloc_type>
  void
  TAO_Buffer_Allocator<handler_type, alloc_type>::release (handler_type *ptr)
  {
      ACE_DES_FREE (ptr,
                    allocator_->free,
                    handler_type);
  }
}

#endif /* TAO_BUFFER_ALLOCATOR_T_CPP */