c: Implement the C implementation of the bhash module
This commit is contained in:
46
c/bhash/inc/bhash.h
Normal file
46
c/bhash/inc/bhash.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef BHASH_H_INCLUDED
|
||||
#define BHASH_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define BHASH_MOD32_ERR UINT32_MAX
|
||||
|
||||
typedef struct bhash bhash_t;
|
||||
|
||||
struct bhash
|
||||
{
|
||||
uint8_t *bh_data; /* Current data buffer */
|
||||
size_t bh_len; /* Data length */
|
||||
double bh_bits_avail; /* Bits available */
|
||||
double bh_bits_used; /* Bits used */
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize new instance of Bhash
|
||||
*/
|
||||
void bhash_init(bhash_t *bh, const void *data, size_t data_len);
|
||||
|
||||
/*
|
||||
* Destroy a bhash object and its associated data
|
||||
*/
|
||||
void bhash_fini(bhash_t *bh);
|
||||
|
||||
/*
|
||||
* Perform a divison of the whole bhash data using the 32-bit `mod` variable
|
||||
* and return the 32-bit reminder.
|
||||
*
|
||||
* This function returns BHASH_MOD32_ERR on error.
|
||||
*/
|
||||
uint32_t bhash_mod32(bhash_t *bh, uint32_t mod);
|
||||
|
||||
/*
|
||||
* Return the number of total bits available in hash
|
||||
*/
|
||||
double bhash_bits_avail(bhash_t *bh);
|
||||
|
||||
/*
|
||||
* Return the number of bits used in bhash
|
||||
*/
|
||||
double bhash_bits_used(bhash_t *bh);
|
||||
|
||||
#endif /* BHASH_H_INCLUDED */
|
||||
Reference in New Issue
Block a user