Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Cleanup_Func_Registry.cpp
blob93ef5cb0c8a097f7dfd1cc458f7074ba23c9d5e8
1 #include "tao/Cleanup_Func_Registry.h"
3 #if !defined (__ACE_INLINE__)
4 # include "tao/Cleanup_Func_Registry.inl"
5 #endif /* __ACE_INLINE__ */
7 #include "ace/Log_Msg.h"
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 int
12 TAO_Cleanup_Func_Registry::register_cleanup_function (ACE_CLEANUP_FUNC func,
13 size_t &slot_id)
15 size_t const slot = this->cleanup_funcs_.size ();
17 if (this->cleanup_funcs_.size (slot + 1) != 0)
18 return -1;
20 this->cleanup_funcs_[slot] = func;
21 slot_id = slot;
23 return 0;
26 void
27 TAO_Cleanup_Func_Registry::cleanup (ACE_Array_Base <void *> &ts_objects)
29 size_t const len = ts_objects.size ();
31 // The allocated slot may never have been used. It is therefore
32 // possible that the TSS array size may be less than the cleanup
33 // function size. However, there is still a one-to-one
34 // correspondence between cleanup_func[foo] and ts_object[foo].
36 ACE_ASSERT (len <= this->cleanup_funcs_.size ());
38 /// Cleanup each TSS object.
39 for (size_t i = 0; i < len; ++i)
41 ACE_CLEANUP_FUNC destructor = this->cleanup_funcs_[i];
42 if (destructor != nullptr)
43 destructor (ts_objects[i], nullptr);
47 TAO_END_VERSIONED_NAMESPACE_DECL