From 9d5a312a8bde828ec97bc2e948cc555194417c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 10 Jan 2026 22:58:33 +0100 Subject: [PATCH] Deprecate "address", "size" and "(de)allocate_many" functions from allocators. --- doc/interprocess.qbk | 5 ++++- .../interprocess/allocators/adaptive_pool.hpp | 11 ++++++---- .../interprocess/allocators/allocator.hpp | 12 +++++++++++ .../allocators/cached_adaptive_pool.hpp | 6 ++++++ .../allocators/cached_node_allocator.hpp | 7 ++++--- .../allocators/detail/allocator_common.hpp | 20 +++++++++++++++---- .../allocators/node_allocator.hpp | 9 ++++++--- .../allocators/private_adaptive_pool.hpp | 9 ++++++--- .../allocators/private_node_allocator.hpp | 9 ++++++--- 9 files changed, 67 insertions(+), 21 deletions(-) diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index d440258..cc4ae1a 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -6878,9 +6878,12 @@ thank them: * Changed the interface of [link managed_memory_segment_advanced_features.managed_memory_segment_multiple_allocations Multiple allocation functions] (still experimental and API/ABI unstable) to support alignment. -Added `BOOST_HEADER_DEPRECATED` to ` headers. They were deprecated several releases ago, but this +* Added `BOOST_HEADER_DEPRECATED` to ` headers. They were deprecated several releases ago, but this message will annoy existing users to switch to Boost.Container headers. +* Deprecated `size()`, `allocate_many` and `deallocate_many`, `address` and `size` functions for allocators. They were not used in + Boost.Container and will be removed in the future. + * Fixed bugs: * [@https://github.com/boostorg/interprocess/issues/242 GitHub #242 (['"Cygwin compatibility issues"])]. * [@https://github.com/boostorg/interprocess/issues/247 GitHub #247 (['"destruction of move-constructed map using private_adaptive_pool triggers Assertion"])]. diff --git a/include/boost/interprocess/allocators/adaptive_pool.hpp b/include/boost/interprocess/allocators/adaptive_pool.hpp index 4fe5a66..479856e 100644 --- a/include/boost/interprocess/allocators/adaptive_pool.hpp +++ b/include/boost/interprocess/allocators/adaptive_pool.hpp @@ -425,10 +425,12 @@ class adaptive_pool //!Returns address of mutable object. //!Never throws + //!This function is deprecated and will be removed in the future pointer address(reference value) const; //!Returns address of non mutable object. //!Never throws + //!This function is deprecated and will be removed in the future const_pointer address(const_reference value) const; //! Requires: Uses-allocator construction of T with allocator argument @@ -447,22 +449,22 @@ class adaptive_pool //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. This size only works for memory allocated with //!allocate, allocation_command and allocate_many. + //!This function is deprecated and will be removed in the future size_type size(const pointer &p) const; - pointer allocation_command(boost::interprocess::allocation_type command, - size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse); - //!Allocates many elements of size elem_size in a contiguous block //!of memory. The minimum number to be allocated is min_elements, //!the preferred and maximum number is //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated - //!with deallocate(...) + //!with deallocate(...). + //!This function is deprecated and will be removed in the future void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain); //!Allocates n_elements elements, each one of size elem_sizes[i]in a //!contiguous block //!of memory. The elements must be deallocated + //!This function is deprecated and will be removed in the future void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain); //!Allocates many elements of size elem_size in a contiguous block @@ -471,6 +473,7 @@ class adaptive_pool //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void deallocate_many(multiallocation_chain &chain); //!Allocates just one object. Memory allocated with this function diff --git a/include/boost/interprocess/allocators/allocator.hpp b/include/boost/interprocess/allocators/allocator.hpp index 47fcaad..6e07257 100644 --- a/include/boost/interprocess/allocators/allocator.hpp +++ b/include/boost/interprocess/allocators/allocator.hpp @@ -215,7 +215,9 @@ class allocator //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. This size only works for memory allocated with //!allocate, allocation_command and allocate_many. + //!This function is deprecated and will be removed in the future BOOST_INTERPROCESS_NODISCARD + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") size_type size(const pointer &p) const { return (size_type)mp_mngr->size(ipcdetail::to_raw_pointer(p))/sizeof(T); @@ -237,6 +239,8 @@ class allocator //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain) { if(size_overflows(elem_size)){ @@ -248,6 +252,8 @@ class allocator //!Allocates n_elements elements, each one of size elem_sizes[i]in a //!contiguous block //!of memory. The elements must be deallocated + //!This function is deprecated and will be removed in the future + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain) { mp_mngr->allocate_many(elem_sizes, n_elements, sizeof(T), boost::container::dtl::alignment_of::value, chain); @@ -259,6 +265,8 @@ class allocator //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") void deallocate_many(multiallocation_chain &chain) { mp_mngr->deallocate_many(chain); } @@ -295,13 +303,17 @@ class allocator //!Returns address of mutable object. //!Never throws + //!This function is deprecated and will be removed in the future BOOST_INTERPROCESS_NODISCARD + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") pointer address(reference value) const { return pointer(boost::container::dtl::addressof(value)); } //!Returns address of non mutable object. //!Never throws + //!This function is deprecated and will be removed in the future BOOST_INTERPROCESS_NODISCARD + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") const_pointer address(const_reference value) const { return const_pointer(boost::container::dtl::addressof(value)); } }; diff --git a/include/boost/interprocess/allocators/cached_adaptive_pool.hpp b/include/boost/interprocess/allocators/cached_adaptive_pool.hpp index b914a74..40e4631 100644 --- a/include/boost/interprocess/allocators/cached_adaptive_pool.hpp +++ b/include/boost/interprocess/allocators/cached_adaptive_pool.hpp @@ -288,10 +288,12 @@ class cached_adaptive_pool //!Returns address of mutable object. //!Never throws + //!This function is deprecated and will be removed in the future pointer address(reference value) const; //!Returns address of non mutable object. //!Never throws + //!This function is deprecated and will be removed in the future const_pointer address(const_reference value) const; //! Requires: Uses-allocator construction of T with allocator argument @@ -310,6 +312,7 @@ class cached_adaptive_pool //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. This size only works for memory allocated with //!allocate, allocation_command and allocate_many. + //!This function is deprecated and will be removed in the future size_type size(const pointer &p) const; pointer allocation_command(boost::interprocess::allocation_type command, @@ -321,11 +324,13 @@ class cached_adaptive_pool //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain); //!Allocates n_elements elements, each one of size elem_sizes[i]in a //!contiguous block //!of memory. The elements must be deallocated + //!This function is deprecated and will be removed in the future void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain); //!Allocates many elements of size elem_size in a contiguous block @@ -334,6 +339,7 @@ class cached_adaptive_pool //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void deallocate_many(multiallocation_chain &chain); //!Allocates just one object. Memory allocated with this function diff --git a/include/boost/interprocess/allocators/cached_node_allocator.hpp b/include/boost/interprocess/allocators/cached_node_allocator.hpp index 1a1bc3b..582b3ee 100644 --- a/include/boost/interprocess/allocators/cached_node_allocator.hpp +++ b/include/boost/interprocess/allocators/cached_node_allocator.hpp @@ -285,22 +285,22 @@ class cached_node_allocator //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. This size only works for memory allocated with //!allocate, allocation_command and allocate_many. + //!This function is deprecated and will be removed in the future size_type size(const pointer &p) const; - pointer allocation_command(boost::interprocess::allocation_type command, - size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse); - //!Allocates many elements of size elem_size in a contiguous block //!of memory. The minimum number to be allocated is min_elements, //!the preferred and maximum number is //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain); //!Allocates n_elements elements, each one of size elem_sizes[i]in a //!contiguous block //!of memory. The elements must be deallocated + //!This function is deprecated and will be removed in the future void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain); //!Allocates many elements of size elem_size in a contiguous block @@ -309,6 +309,7 @@ class cached_node_allocator //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void deallocate_many(multiallocation_chain &chain); //!Allocates just one object. Memory allocated with this function diff --git a/include/boost/interprocess/allocators/detail/allocator_common.hpp b/include/boost/interprocess/allocators/detail/allocator_common.hpp index 46480ee..bd22b6b 100644 --- a/include/boost/interprocess/allocators/detail/allocator_common.hpp +++ b/include/boost/interprocess/allocators/detail/allocator_common.hpp @@ -368,7 +368,9 @@ class array_allocation_impl //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. This size only works for memory allocated with //!allocate, allocation_command and allocate_many. + //!This function is deprecated and will be removed in the future BOOST_INTERPROCESS_NODISCARD + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") size_type size(const pointer &p) const { return (size_type)this->derived()->get_segment_manager()->size(ipcdetail::to_raw_pointer(p))/sizeof(T); @@ -391,20 +393,24 @@ class array_allocation_impl //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) - void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain) + //!This function is deprecated and will be removed in the future + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") + void allocate_many(size_type elem_size, size_type num_elements, size_type alignment, multiallocation_chain &chain) { if(size_overflows(elem_size)){ throw bad_alloc(); } - this->derived()->get_segment_manager()->allocate_many(elem_size*sizeof(T), num_elements, chain); + this->derived()->get_segment_manager()->allocate_many(elem_size*sizeof(T), num_elements, alignment, chain); } //!Allocates n_elements elements, each one of size elem_sizes[i]in a //!contiguous block //!of memory. The elements must be deallocated - void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain) + //!This function is deprecated and will be removed in the future + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") + void allocate_many(const size_type *elem_sizes, size_type n_elements, size_type alignment, multiallocation_chain &chain) { - this->derived()->get_segment_manager()->allocate_many(elem_sizes, n_elements, sizeof(T), chain); + this->derived()->get_segment_manager()->allocate_many(elem_sizes, n_elements, sizeof(T), alignment, chain); } //!Allocates many elements of size elem_size in a contiguous block @@ -413,6 +419,8 @@ class array_allocation_impl //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") void deallocate_many(multiallocation_chain &chain) { this->derived()->get_segment_manager()->deallocate_many(chain); } @@ -424,13 +432,17 @@ class array_allocation_impl //!Returns address of mutable object. //!Never throws + //!This function is deprecated and will be removed in the future BOOST_INTERPROCESS_NODISCARD + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") pointer address(reference value) const { return pointer(boost::container::dtl::addressof(value)); } //!Returns address of non mutable object. //!Never throws + //!This function is deprecated and will be removed in the future BOOST_INTERPROCESS_NODISCARD + BOOST_DEPRECATED("This function is deprecated and will be removed in the future") const_pointer address(const_reference value) const { return const_pointer(boost::container::dtl::addressof(value)); } diff --git a/include/boost/interprocess/allocators/node_allocator.hpp b/include/boost/interprocess/allocators/node_allocator.hpp index 19cf846..2a0ecc8 100644 --- a/include/boost/interprocess/allocators/node_allocator.hpp +++ b/include/boost/interprocess/allocators/node_allocator.hpp @@ -405,10 +405,12 @@ class node_allocator //!Returns address of mutable object. //!Never throws + //!This function is deprecated and will be removed in the future pointer address(reference value) const; //!Returns address of non mutable object. //!Never throws + //!This function is deprecated and will be removed in the future const_pointer address(const_reference value) const; //! Requires: Uses-allocator construction of T with allocator argument @@ -427,22 +429,22 @@ class node_allocator //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. This size only works for memory allocated with //!allocate, allocation_command and allocate_many. + //!This function is deprecated and will be removed in the future size_type size(const pointer &p) const; - pointer allocation_command(boost::interprocess::allocation_type command, - size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse); - //!Allocates many elements of size elem_size in a contiguous block //!of memory. The minimum number to be allocated is min_elements, //!the preferred and maximum number is //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain); //!Allocates n_elements elements, each one of size elem_sizes[i]in a //!contiguous block //!of memory. The elements must be deallocated + //!This function is deprecated and will be removed in the future void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain); //!Allocates many elements of size elem_size in a contiguous block @@ -451,6 +453,7 @@ class node_allocator //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void deallocate_many(multiallocation_chain &chain); //!Allocates just one object. Memory allocated with this function diff --git a/include/boost/interprocess/allocators/private_adaptive_pool.hpp b/include/boost/interprocess/allocators/private_adaptive_pool.hpp index cabc7ad..6871ba5 100644 --- a/include/boost/interprocess/allocators/private_adaptive_pool.hpp +++ b/include/boost/interprocess/allocators/private_adaptive_pool.hpp @@ -452,10 +452,12 @@ class private_adaptive_pool //!Returns address of mutable object. //!Never throws + //!This function is deprecated and will be removed in the future pointer address(reference value) const; //!Returns address of non mutable object. //!Never throws + //!This function is deprecated and will be removed in the future const_pointer address(const_reference value) const; //! Requires: Uses-allocator construction of T with allocator argument @@ -474,22 +476,22 @@ class private_adaptive_pool //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. This size only works for memory allocated with //!allocate, allocation_command and allocate_many. + //!This function is deprecated and will be removed in the future size_type size(const pointer &p) const; - pointer allocation_command(boost::interprocess::allocation_type command, - size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse); - //!Allocates many elements of size elem_size in a contiguous block //!of memory. The minimum number to be allocated is min_elements, //!the preferred and maximum number is //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain); //!Allocates n_elements elements, each one of size elem_sizes[i]in a //!contiguous block //!of memory. The elements must be deallocated + //!This function is deprecated and will be removed in the future void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain); //!Allocates many elements of size elem_size in a contiguous block @@ -498,6 +500,7 @@ class private_adaptive_pool //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void deallocate_many(multiallocation_chain &chain); //!Allocates just one object. Memory allocated with this function diff --git a/include/boost/interprocess/allocators/private_node_allocator.hpp b/include/boost/interprocess/allocators/private_node_allocator.hpp index 40a3412..b32f91d 100644 --- a/include/boost/interprocess/allocators/private_node_allocator.hpp +++ b/include/boost/interprocess/allocators/private_node_allocator.hpp @@ -428,10 +428,12 @@ class private_node_allocator //!Returns address of mutable object. //!Never throws + //!This function is deprecated and will be removed in the future pointer address(reference value) const; //!Returns address of non mutable object. //!Never throws + //!This function is deprecated and will be removed in the future const_pointer address(const_reference value) const; //! Requires: Uses-allocator construction of T with allocator argument @@ -450,22 +452,22 @@ class private_node_allocator //!Returns maximum the number of objects the previously allocated memory //!pointed by p can hold. This size only works for memory allocated with //!allocate, allocation_command and allocate_many. + //!This function is deprecated and will be removed in the future size_type size(const pointer &p) const; - pointer allocation_command(boost::interprocess::allocation_type command, - size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse); - //!Allocates many elements of size elem_size in a contiguous block //!of memory. The minimum number to be allocated is min_elements, //!the preferred and maximum number is //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain); //!Allocates n_elements elements, each one of size elem_sizes[i]in a //!contiguous block //!of memory. The elements must be deallocated + //!This function is deprecated and will be removed in the future void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain); //!Allocates many elements of size elem_size in a contiguous block @@ -474,6 +476,7 @@ class private_node_allocator //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) + //!This function is deprecated and will be removed in the future void deallocate_many(multiallocation_chain &chain); //!Allocates just one object. Memory allocated with this function