move stuff in common, clang-format, update copyright

This commit is contained in:
Guillaume Meunier
2022-11-13 11:00:04 +01:00
parent 294c4f81ba
commit 4baf2b17eb
62 changed files with 2291 additions and 2846 deletions
+38 -37
View File
@@ -39,52 +39,53 @@
#define __RS_H_
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/* use small value to save memory */
#define DATA_SHARDS_MAX 2048
typedef struct _reed_solomon
{
int data_shards;
int parity_shards;
int shards;
unsigned char *m;
unsigned char *parity;
} reed_solomon;
typedef struct _reed_solomon
{
int data_shards;
int parity_shards;
int shards;
unsigned char * m;
unsigned char * parity;
} reed_solomon;
/**
* MUST initial one time
* */
void
reed_solomon_init(void);
/**
* MUST initial one time
* */
void
reed_solomon_init(void);
reed_solomon *
reed_solomon_new(int data_shards, int parity_shards);
void
reed_solomon_release(reed_solomon *rs);
reed_solomon *
reed_solomon_new(int data_shards, int parity_shards);
void
reed_solomon_release(reed_solomon * rs);
/**
* encode a big size of buffer
* input:
* rs
* nr_shards: assert(0 == nr_shards % rs->data_shards)
* shards[nr_shards][block_size]
* */
int
reed_solomon_encode(reed_solomon *rs, unsigned char **shards, int nr_shards, int block_size);
/**
* encode a big size of buffer
* input:
* rs
* nr_shards: assert(0 == nr_shards % rs->data_shards)
* shards[nr_shards][block_size]
* */
int
reed_solomon_encode(reed_solomon * rs, unsigned char ** shards, int nr_shards, int block_size);
/**
* reconstruct a big size of buffer
* input:
* rs
* nr_shards: assert(0 == nr_shards % rs->data_shards)
* shards[nr_shards][block_size]
* marks[nr_shards] marks as errors
* */
int
reed_solomon_reconstruct(reed_solomon *rs, unsigned char **shards, unsigned char *marks, int nr_shards, int block_size);
/**
* reconstruct a big size of buffer
* input:
* rs
* nr_shards: assert(0 == nr_shards % rs->data_shards)
* shards[nr_shards][block_size]
* marks[nr_shards] marks as errors
* */
int
reed_solomon_reconstruct(reed_solomon * rs, unsigned char ** shards, unsigned char * marks, int nr_shards, int block_size);
#ifdef __cplusplus
};