23 kv->capacity = capacity;
29 for (
size_t i = 0; i < capacity; i++) {
43 for (
size_t i = 0; i <
kv->capacity; i++)
45 if (
kv->used[i] &&
kv->keys[i] == key)
85 memcpy(&
kv->values[index *
kv->esize], value,
kv->esize);
90 for (
size_t i = 0; i <
kv->capacity; i++)
117 return &
kv->values[index *
kv->esize];
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.
static int kv_find(const kv_store_t *kv, uint32_t key, size_t *index)
Finds the index of a given key in the store.
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_remove(kv_store_t *kv, uint32_t key)
Removes a key-value pair from the store.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.