High Performance OPC UA Server SDK
1.1.0.158
|
Functions for managing the memory layout. More...
Data Structures | |
struct | memory_pool_config |
Configures the size of one memory pool. More... | |
struct | memory_layout |
Memory layout structure. More... | |
Macros | |
#define | MEMORY_INVALID_INDEX (size_t)-1 |
Functions | |
unsigned int | memory_uniqueid (void) |
unsigned int | ipc_counter (void) |
int | memory_layout_init (struct memory_layout *config) |
void | memory_layout_clear (struct memory_layout *config) |
The clear functions is actually not necessary, because the memory is provided by the caller of memory_layout_init. More... | |
void | memory_layout_set (void *mem) |
Set existing and initialized memory. More... | |
void * | memory_layout_get (void) |
Returns the address of the global memory segment. More... | |
void | memory_layout_set_prop (unsigned int index, void *data) |
Stores a shared memory property. More... | |
void * | memory_layout_get_prop (unsigned int index) |
Returns a shared memory property. More... | |
void | memory_layout_set_prop_uint (unsigned int index, unsigned int val) |
Stores a shared memory property from type unsigned int. More... | |
unsigned int | memory_layout_get_prop_uint (unsigned int index) |
Returns a shared memory property from type unsigned int. More... | |
void | memory_layout_set_prop_int (unsigned int index, int val) |
Stores a shared memory property from type int. More... | |
int | memory_layout_get_prop_int (unsigned int index) |
Returns a shared memory property from type int. More... | |
struct mem_objectpool * | memory_get_pool (unsigned int pool_id) |
Returns the object pool for the given pool_id. More... | |
void * | memory_pool_alloc (unsigned int pool_id) |
Allocates one object of the given pool. More... | |
void * | memory_pool_calloc (unsigned int pool_id) |
Allocates one object of the given pool and zeros the memory. More... | |
void | memory_pool_free (unsigned int pool_id, void *ptr) |
Give the object ptr back to the memory pool. More... | |
void * | memory_pool_get (unsigned int pool_id, int index) |
Returns the object with the given index from the memory pool. More... | |
size_t | memory_pool_indexof (unsigned int pool_id, const void *ptr) |
This returns the index of an object inside a memory pool. More... | |
void * | memory_malloc (size_t size) |
void | memory_free (void *ptr) |
void * | memory_calloc (size_t nmemb, size_t size) |
void * | memory_realloc (void *ptr, size_t size) |
Functions for managing the memory layout.
The UA SDK makes use of various memory pools, which need to be setup properly. For this one big block of memory is allocated at startup and is then devided into several memory pools.
struct mem_objectpool* memory_get_pool | ( | unsigned int | pool_id | ) |
Returns the object pool for the given pool_id.
The pool_id must be within 1..num_pools-1 (0=heap).
void memory_layout_clear | ( | struct memory_layout * | config | ) |
The clear functions is actually not necessary, because the memory is provided by the caller of memory_layout_init.
But we can do some statistic and memory leak detection here.
void* memory_layout_get | ( | void | ) |
Returns the address of the global memory segment.
void* memory_layout_get_prop | ( | unsigned int | index | ) |
Returns a shared memory property.
index | property index |
int memory_layout_get_prop_int | ( | unsigned int | index | ) |
Returns a shared memory property from type int.
index | property index |
unsigned int memory_layout_get_prop_uint | ( | unsigned int | index | ) |
Returns a shared memory property from type unsigned int.
index | property index |
int memory_layout_init | ( | struct memory_layout * | config | ) |
< sum of all pools + header for validation in SHM
< sum of all pools in private memory
< size of memory header
< size of heap memory pool
< size of object pool
void memory_layout_set | ( | void * | mem | ) |
Set existing and initialized memory.
This is used when opening an existing shared memory segment, which was already initialized by the master process.
void memory_layout_set_prop | ( | unsigned int | index, |
void * | data | ||
) |
Stores a shared memory property.
index | property index. |
data | user data pointer. |
void memory_layout_set_prop_int | ( | unsigned int | index, |
int | val | ||
) |
Stores a shared memory property from type int.
index | property index. |
val | user data. |
void memory_layout_set_prop_uint | ( | unsigned int | index, |
unsigned int | val | ||
) |
Stores a shared memory property from type unsigned int.
index | property index. |
val | user data. |
void* memory_pool_alloc | ( | unsigned int | pool_id | ) |
Allocates one object of the given pool.
pool_id | memory pool identifier |
Allocates one object of the given pool.
These functions are needed buffer_alloc in based library, but are not necessary in xml2bin.
void* memory_pool_calloc | ( | unsigned int | pool_id | ) |
Allocates one object of the given pool and zeros the memory.
pool_id | memory pool identifier |
void memory_pool_free | ( | unsigned int | pool_id, |
void * | ptr | ||
) |
Give the object ptr
back to the memory pool.
pool_id | memory pool identifier |
ptr | object to free |
void* memory_pool_get | ( | unsigned int | pool_id, |
int | index | ||
) |
Returns the object with the given index from the memory pool.
This is used for fast index based access of memory pool objects.
size_t memory_pool_indexof | ( | unsigned int | pool_id, |
const void * | ptr | ||
) |
This returns the index of an object inside a memory pool.
This index can be used as a handle to the object.