- Explicitly static_assert if raw pointers are used when calling "grow" as it was never supported.

- Update documentation to state this.

- Fixes #220 ("basic_managed_shared_memory::grow() do not return when using raw pointers")
This commit is contained in:
Ion Gaztañaga
2024-09-26 14:51:04 +02:00
parent e7ed694f31
commit a22d4986d7
4 changed files with 13 additions and 1 deletions

View File

@@ -105,6 +105,8 @@ class basic_managed_external_buffer
return *this;
}
//!Tries to resize internal heap memory so that
//!we have room for more objects.
void grow(size_type extra_bytes)
{ base_t::grow(extra_bytes); }

View File

@@ -273,6 +273,9 @@ class basic_managed_mapped_file
//!
//!This function is not synchronized so no other thread or process should
//!be reading or writing the file
//!
//!Since the memory will be remapped after the underlying file
//!is grown, it can't work with segments using raw pointers.
static bool grow(const char *filename, size_type extra_bytes)
{
return base_t::template grow

View File

@@ -276,6 +276,9 @@ class basic_managed_shared_memory
//!
//!This function is not synchronized so no other thread or process should
//!be reading or writing the file
//!
//!Since the memory will be remapped after the underlying shared memory
//!is grown, it can't work with segments using raw pointers.
static bool grow(const char *shmname, size_type extra_bytes)
{
return base_t::template grow

View File

@@ -244,7 +244,11 @@ class segment_manager_base
//!Increases managed memory in extra_size bytes more. This only works
//!with single-segment management.
void grow(size_type extra_size)
{ MemoryAlgorithm::grow(extra_size); }
{
//Growing managed segments that use raw pointers is UB, so disallow it.
BOOST_INTERPROCESS_STATIC_ASSERT(!(ipcdetail::is_same<void*, void_pointer>::value));
MemoryAlgorithm::grow(extra_size);
}
//!Decreases managed memory to the minimum. This only works
//!with single-segment management.