|
Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
#include <stdint.h>#include <stddef.h>Go to the source code of this file.
Data Structures | |
| struct | kv_store_t |
Functions | |
| void | kv_init (kv_store_t *kv, size_t capacity, size_t esize, uint32_t *keys, void *values, uint8_t *used) |
| Initializes a key-value store. | |
| int | kv_exists (const kv_store_t *kv, uint32_t key) |
| Checks if a key exists in the store. | |
| int | kv_set (kv_store_t *kv, uint32_t key, const void *value) |
| Sets a value for a given key. | |
| void * | kv_get (const kv_store_t *kv, uint32_t key) |
| Retrieves the value associated with a given key. | |
| int | kv_remove (kv_store_t *kv, uint32_t key) |
| Removes a key-value pair from the store. | |
| struct kv_store_t |
Definition at line 11 of file kv_store.h.
| Data Fields | ||
|---|---|---|
| size_t | capacity | |
| size_t | esize | |
| uint32_t * | keys | |
| uint8_t * | used | |
| uint8_t * | values | |
| int kv_exists | ( | const kv_store_t * | kv, |
| uint32_t | key ) |
Checks if a key exists in the store.
| kv | Pointer to the kv_store_t structure. |
| key | The key to check for existence. |
Definition at line 64 of file kv_store.c.
| void * kv_get | ( | const kv_store_t * | kv, |
| uint32_t | key ) |
Retrieves the value associated with a given key.
| kv | Pointer to the kv_store_t structure. |
| key | The key to retrieve the value for. |
Definition at line 111 of file kv_store.c.
Referenced by get_transfer_id().
| void kv_init | ( | kv_store_t * | kv, |
| size_t | capacity, | ||
| size_t | esize, | ||
| uint32_t * | keys, | ||
| void * | values, | ||
| uint8_t * | used ) |
Initializes a key-value store.
| kv | Pointer to the kv_store_t structure to initialize. |
| capacity | The maximum number of key-value pairs the store can hold. |
| esize | The size in bytes of each value element. |
| keys | Pointer to an array of uint32_t for storing keys. At least "capacity" long. |
| values | Pointer to the memory area for storing values. At least "capacity * esize" long. |
| used | Pointer to an array of uint8_t flags indicating if a slot is used. At least "capacity" long. |
Definition at line 20 of file kv_store.c.
References kv.
Referenced by uavcanInitIface().
| int kv_remove | ( | kv_store_t * | kv, |
| uint32_t | key ) |
Removes a key-value pair from the store.
| kv | Pointer to the kv_store_t structure. |
| key | The key to remove. |
Definition at line 127 of file kv_store.c.
| int kv_set | ( | kv_store_t * | kv, |
| uint32_t | key, | ||
| const void * | value ) |
Sets a value for a given key.
If the key already exists, its value is updated. If not, a new key-value pair is inserted into the first available slot. If the store is full, the operation fails.
| kv | Pointer to the kv_store_t structure. |
| key | The key to set. |
| value | Pointer to the value to store. Value will be memcpy in the store, so the pointer does not need to be valid afterward. |
Definition at line 79 of file kv_store.c.
Referenced by get_transfer_id().