Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
detail Namespace Reference

Internal implementation details - not part of public API. More...

Functions

void * aligned_alloc_impl (size_t alignment, size_t size)
 Platform-specific aligned memory allocation.
 
void aligned_free_impl (void *ptr)
 Platform-specific aligned memory deallocation.
 

Detailed Description

Internal implementation details - not part of public API.

Function Documentation

◆ aligned_alloc_impl()

void * detail::aligned_alloc_impl ( size_t alignment,
size_t size )
inline

Platform-specific aligned memory allocation.

Parameters
alignmentMemory alignment (must be power of 2)
sizeSize in bytes
Returns
Pointer to aligned memory or nullptr on failure

Definition at line 35 of file memory_pool.h.

35 {
36#ifdef _MSC_VER
37 // MSVC doesn't support std::aligned_alloc
38 // Size must be a multiple of alignment for _aligned_malloc
39 size_t aligned_size = (size + alignment - 1) & ~(alignment - 1);
40 return _aligned_malloc(aligned_size, alignment);
41#else
42 // POSIX/C11 aligned_alloc requires size to be multiple of alignment
43 size_t aligned_size = (size + alignment - 1) & ~(alignment - 1);
44 return std::aligned_alloc(alignment, aligned_size);
45#endif
46}

Referenced by kcenon::monitoring::memory_pool::grow_pool(), and kcenon::monitoring::memory_pool::initialize_pool().

Here is the caller graph for this function:

◆ aligned_free_impl()

void detail::aligned_free_impl ( void * ptr)
inline

Platform-specific aligned memory deallocation.

Parameters
ptrPointer to free

Definition at line 52 of file memory_pool.h.

52 {
53#ifdef _MSC_VER
54 _aligned_free(ptr);
55#else
56 std::free(ptr);
57#endif
58}

Referenced by kcenon::monitoring::memory_pool::operator=(), and kcenon::monitoring::memory_pool::~memory_pool().

Here is the caller graph for this function: