Skip to content

Commit

Permalink
CP-492 Add documentation for setting allocation strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
poetinger authored and eboasson committed Oct 23, 2023
1 parent d6684dc commit c73e59a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/manual/config/allocation-config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _allocation_config:

*********************
Memory Allocation Configuration
*********************

Users have the flexibility to customize the memory allocation strategy for |var-project| by leveraging their own memory allocation libraries. To utilise your preferred memory allocation functions, follow these steps:

1. Include `dds/ddsrt/heap.h`
To gain access to `ddsrt_allocation_ops_t` and `ddsrt_set_allocator`.

2. Set the allocation operations
Define a `ddsrt_allocation_ops_t` structure that contains pointers to the functions you want to use for memory allocation and deallocation (`malloc`, `calloc`, `realloc`, and `free`).

3. Provide `ddsrt` the operations
Utilize the `ddsrt_set_allocator` function to set the ops chosen in step 2.

4. Link with custom library
Compile and link your application with the library that contains the functions specified in the `ddsrt_allocation_ops_t` structure created in step 2.

By following these steps, you can tailor the memory allocation mechanism of |var-project| to meet your specific requirements.
1 change: 1 addition & 0 deletions docs/manual/config/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ To determine the information included in the log file, change the :ref:`Tracing/
conformance
config_file_reference
benchmarking
allocation-config

0 comments on commit c73e59a

Please sign in to comment.