// Buffer_Allocator_T.cpp,v 1.1 2004/06/23 12:26:31 jwillemsen Exp

#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 */
