木头云 91e4489a55 refactor(buffer): rename 'additional' parameter to 'mem_to_free' for clarity
Header changes (include/libipc/buffer.h):
- Rename: additional → mem_to_free (better semantic name)
- Add documentation comments explaining the parameter's purpose
- Clarifies that mem_to_free is passed to destructor instead of p
- Use case: when data pointer is offset into a larger allocation

Implementation changes (src/libipc/buffer.cpp):
- Update parameter name in constructor implementation
- No logic changes, just naming improvement

Test changes (test/test_buffer.cpp):
- Fix TEST_F(BufferTest, ConstructorWithMemToFree)
- Previous test caused crash: passed stack variable address to destructor
- New test correctly demonstrates the parameter's purpose:
  * Allocate 100-byte block
  * Use offset portion (bytes 25-75) as data
  * Destructor receives original block pointer for proper cleanup
- Prevents double-free and invalid free errors

Semantic explanation:
  buffer(data_ptr, size, destructor, mem_to_free)

  On destruction:
    destructor(mem_to_free ? mem_to_free : data_ptr, size)

  This allows:
    char* block = new char[100];
    char* data = block + 25;
    buffer buf(data, 50, my_free, block);  // Frees 'block', not 'data'
2025-11-30 05:09:56 +00:00
..
buffer.h refactor(buffer): rename 'additional' parameter to 'mem_to_free' for clarity 2025-11-30 05:09:56 +00:00
condition.h Added a cleanup interface for the synchronization facilities 2024-11-17 17:39:03 +08:00
def.h Add a user interface with a custom name prefix. 2023-10-28 16:44:16 +08:00
export.h option(LIBIPC_BUILD_SHARED_LIBS 'Build shared libraries (DLLs).' OFF) 2021-07-10 13:50:46 +08:00
ipc.h Complete the implementation of the clean interface and add unit tests 2024-12-01 19:06:50 +08:00
mutex.h Added a cleanup interface for the synchronization facilities 2024-11-17 17:39:03 +08:00
pool_alloc.h Added a cleanup interface for shared memory handles 2024-11-17 17:35:29 +08:00
rw_lock.h Update rw_lock.h for #143 2025-04-20 13:58:42 +08:00
semaphore.h Added a cleanup interface for the synchronization facilities 2024-11-17 17:39:03 +08:00
shm.h Added a cleanup interface for shared memory handles 2024-11-17 17:35:29 +08:00