Updated logging to include the class/method so that it is more obvious where these...
[ACE_TAO.git] / TAO / tao / Unbounded_Reference_Allocation_Traits_T.h
blob518e876a26a9e10b5bb4579a8429e9ee2c8e5a0a
1 #ifndef guard_unbounded_reference_allocation_traits_hpp
2 #define guard_unbounded_reference_allocation_traits_hpp
3 /**
4 * @file
6 * @brief Details can be found in the documentation for
7 * TAO::details::generic_sequence
9 * @author Carlos O'Ryan
12 #include "tao/Basic_Types.h"
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
16 namespace TAO
18 namespace details
21 template<typename T, class ref_traits, bool dummy>
22 struct unbounded_reference_allocation_traits
24 typedef T value_type;
25 typedef ref_traits reference_traits;
27 inline static CORBA::ULong default_maximum()
29 return 0;
32 inline static value_type * default_buffer_allocation()
34 return 0;
37 inline static value_type * allocbuf(CORBA::ULong maximum)
39 if (maximum == ACE_UINT32_MAX)
41 return 0;
43 value_type * buffer = new value_type[maximum + 1];
44 reinterpret_cast<value_type**>(buffer)[0] = buffer + maximum + 1;
46 // no throw
47 reference_traits::initialize_range(buffer + 1, buffer + maximum + 1);
49 return buffer + 1;
52 inline static value_type * allocbuf_noinit(CORBA::ULong maximum)
54 if (maximum == ACE_UINT32_MAX)
56 return 0;
58 value_type * buffer = new value_type[maximum + 1];
59 reinterpret_cast<value_type**>(buffer)[0] = buffer + maximum + 1;
61 // no throw
62 reference_traits::zero_range(buffer + 1, buffer + maximum + 1);
64 return buffer + 1;
67 inline static void freebuf(value_type * buffer)
69 if(buffer != 0)
71 value_type * begin = buffer - 1;
72 value_type * end = reinterpret_cast<value_type*>(*begin);
73 reference_traits::release_range(buffer, end);
75 buffer = begin;
77 delete[] buffer;
81 } // namespace details
82 } // namespace TAO
84 TAO_END_VERSIONED_NAMESPACE_DECL
86 #endif // guard_unbounded_reference_allocation_traits_hpp