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
21 template<typename T
, class ref_traits
, bool dummy
>
22 struct unbounded_reference_allocation_traits
25 typedef ref_traits reference_traits
;
27 inline static CORBA::ULong
default_maximum()
32 inline static value_type
* default_buffer_allocation()
37 inline static value_type
* allocbuf(CORBA::ULong maximum
)
39 if (maximum
== ACE_UINT32_MAX
)
43 value_type
* buffer
= new value_type
[maximum
+ 1];
44 reinterpret_cast<value_type
**>(buffer
)[0] = buffer
+ maximum
+ 1;
47 reference_traits::initialize_range(buffer
+ 1, buffer
+ maximum
+ 1);
52 inline static value_type
* allocbuf_noinit(CORBA::ULong maximum
)
54 if (maximum
== ACE_UINT32_MAX
)
58 value_type
* buffer
= new value_type
[maximum
+ 1];
59 reinterpret_cast<value_type
**>(buffer
)[0] = buffer
+ maximum
+ 1;
62 reference_traits::zero_range(buffer
+ 1, buffer
+ maximum
+ 1);
67 inline static void freebuf(value_type
* buffer
)
71 value_type
* begin
= buffer
- 1;
72 value_type
* end
= reinterpret_cast<value_type
*>(*begin
);
73 reference_traits::release_range(buffer
, end
);
81 } // namespace details
84 TAO_END_VERSIONED_NAMESPACE_DECL
86 #endif // guard_unbounded_reference_allocation_traits_hpp