1 #ifndef guard_unbounded_reference_allocation_traits_hpp
2 #define guard_unbounded_reference_allocation_traits_hpp
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
20 template<typename T
, class ref_traits
, bool dummy
>
21 struct unbounded_reference_allocation_traits
24 typedef ref_traits reference_traits
;
26 inline static CORBA::ULong
default_maximum()
31 inline static value_type
* default_buffer_allocation()
36 inline static value_type
* allocbuf(CORBA::ULong maximum
)
38 if (maximum
== ACE_UINT32_MAX
)
42 value_type
* buffer
= new value_type
[maximum
+ 1];
43 reinterpret_cast<value_type
**>(buffer
)[0] = buffer
+ maximum
+ 1;
46 reference_traits::initialize_range(buffer
+ 1, buffer
+ maximum
+ 1);
51 inline static value_type
* allocbuf_noinit(CORBA::ULong maximum
)
53 if (maximum
== ACE_UINT32_MAX
)
57 value_type
* buffer
= new value_type
[maximum
+ 1];
58 reinterpret_cast<value_type
**>(buffer
)[0] = buffer
+ maximum
+ 1;
61 reference_traits::zero_range(buffer
+ 1, buffer
+ maximum
+ 1);
66 inline static void freebuf(value_type
* buffer
)
70 value_type
* begin
= buffer
- 1;
71 value_type
* end
= reinterpret_cast<value_type
*>(*begin
);
72 reference_traits::release_range(buffer
, end
);
79 } // namespace details
82 TAO_END_VERSIONED_NAMESPACE_DECL
84 #endif // guard_unbounded_reference_allocation_traits_hpp