mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
- 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:
@@ -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); }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user