Skip to content

Commit

Permalink
Update docs for the basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
vinser52 committed Nov 22, 2024
1 parent d8015b3 commit 4d0a4a5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions scripts/docs_config/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,31 @@ the OS Memory Provider API::

#include "umf/providers/provider_os_memory.h"

Get a pointer to the OS memory provider operations struct and
a copy of default parameters::
Get a pointer to the OS memory provider operations struct::

umf_memory_provider_ops_t *provider_ops = umfOsMemoryProviderOps();
umf_os_memory_provider_params_t params = umfOsMemoryProviderParamsDefault();

Get a default memory provider parameters. The handle to the parameters object
is returned by the :any:`umfOsMemoryProviderParamsCreate` function::

umf_os_memory_provider_params_handle_t params = NULL;

res = umfOsMemoryProviderParamsCreate(&params);
if (res != UMF_RESULT_SUCCESS) {
printf("Failed to create OS memory provider params!\n");
return -1;
}

The handle to created memory ``provider`` object is returned as the last argument
of :any:`umfMemoryProviderCreate`::

umf_memory_provider_handle_t provider;
umfMemoryProviderCreate(provider_ops, &params, &provider);

With this handle we can allocate a chunk of memory, call :any:`umfMemoryProviderAlloc`::
The ``params`` object can be destroyed after the provider is created::
umfOsMemoryProviderParamsDestroy(params);

With the ``provider`` handle we can allocate a chunk of memory, call :any:`umfMemoryProviderAlloc`::

size_t alloc_size = 5000;
size_t alignment = 0;
Expand Down

0 comments on commit 4d0a4a5

Please sign in to comment.