mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 13:03:13 +00:00
acc39a4bc0
* Api Symbols: replace asserts with checks * Api Symbols: replace asserts with checks part 2 * Update no args function signatures with void, to help compiler to track incorrect usage * More unavoidable void * Update PVS config and code to make it happy * Format sources * nfc: fix checks * dead code cleanup & include fixes Co-authored-by: gornekich <n.gorbadey@gmail.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su>
79 lines
No EOL
1.4 KiB
C
79 lines
No EOL
1.4 KiB
C
#pragma once
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct VarintPair VarintPair;
|
|
|
|
/**
|
|
* @brief Allocate a new VarintPair instance
|
|
*
|
|
* VarintPair is a buffer that holds pair of varint values
|
|
* @return VarintPair*
|
|
*/
|
|
VarintPair* varint_pair_alloc(void);
|
|
|
|
/**
|
|
* @brief Free a VarintPair instance
|
|
*
|
|
* @param pair
|
|
*/
|
|
void varint_pair_free(VarintPair* pair);
|
|
|
|
/**
|
|
* @brief Write varint pair to buffer
|
|
*
|
|
* @param pair
|
|
* @param first
|
|
* @param value
|
|
* @return bool pair complete and needs to be written
|
|
*/
|
|
bool varint_pair_pack(VarintPair* pair, bool first, uint32_t value);
|
|
|
|
/**
|
|
* @brief Get pointer to varint pair buffer
|
|
*
|
|
* @param pair
|
|
* @return uint8_t*
|
|
*/
|
|
uint8_t* varint_pair_get_data(VarintPair* pair);
|
|
|
|
/**
|
|
* @brief Get size of varint pair buffer
|
|
*
|
|
* @param pair
|
|
* @return size_t
|
|
*/
|
|
size_t varint_pair_get_size(VarintPair* pair);
|
|
|
|
/**
|
|
* @brief Reset varint pair buffer
|
|
*
|
|
* @param pair
|
|
*/
|
|
void varint_pair_reset(VarintPair* pair);
|
|
|
|
/**
|
|
* @brief Unpack varint pair to uint32_t pair from buffer
|
|
*
|
|
* @param data
|
|
* @param data_length
|
|
* @param value_1
|
|
* @param value_2
|
|
* @param length
|
|
* @return bool
|
|
*/
|
|
bool varint_pair_unpack(
|
|
uint8_t* data,
|
|
size_t data_length,
|
|
uint32_t* value_1,
|
|
uint32_t* value_2,
|
|
size_t* length);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |