added function to free/destroy alg_sig handles
This commit is contained in:
@@ -40,6 +40,7 @@ typedef struct alg_sig_s
|
||||
} alg_sig_t;
|
||||
|
||||
alg_sig_t *init_alg_sig(int sig_len, int gf_w);
|
||||
void destroy_alg_sig(alg_sig_t* alg_sig_handle);
|
||||
|
||||
int compute_alg_sig(alg_sig_t* alg_sig_handle, char *buf, int len, char *sig);
|
||||
int crc32_build_fast_table();
|
||||
|
||||
@@ -156,6 +156,29 @@ alg_sig_t *init_alg_sig(int sig_len, int gf_w)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void destroy_alg_sig(alg_sig_t* alg_sig_handle)
|
||||
{
|
||||
if (alg_sig_handle == NULL) {
|
||||
return;
|
||||
}
|
||||
if (alg_sig_handle->gf_w == 0) {
|
||||
free(alg_sig_handle);
|
||||
return;
|
||||
}
|
||||
int num_components = alg_sig_handle->sig_len / alg_sig_handle->gf_w;
|
||||
|
||||
free(alg_sig_handle->tbl1_l);
|
||||
free(alg_sig_handle->tbl1_r);
|
||||
if (num_components >= 4) {
|
||||
free(alg_sig_handle->tbl2_l);
|
||||
free(alg_sig_handle->tbl2_r);
|
||||
free(alg_sig_handle->tbl3_l);
|
||||
free(alg_sig_handle->tbl3_r);
|
||||
}
|
||||
free(alg_sig_handle);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int compute_w8_alg_sig_32(alg_sig_t *alg_sig_handle, char *buf, int len, char *sig)
|
||||
{
|
||||
|
||||
@@ -123,6 +123,7 @@ static int basic_xor_test_8_32()
|
||||
free(sigs[num_data]);
|
||||
free(sigs);
|
||||
free(data);
|
||||
destroy_alg_sig(sig_handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -168,6 +169,7 @@ static int basic_xor_test_16_64()
|
||||
free(sigs[num_data]);
|
||||
free(sigs);
|
||||
free(data);
|
||||
destroy_alg_sig(sig_handle);
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -215,6 +217,7 @@ static int basic_xor_test_16_32()
|
||||
free(sigs[num_data]);
|
||||
free(sigs);
|
||||
free(data);
|
||||
destroy_alg_sig(sig_handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user