Skip to content

Commit 7375a0a

Browse files
author
YuanChe Hsu
committed
Rename annoying names containing wrapper or ptr.
1 parent 412f3c1 commit 7375a0a

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

lib/exfes.c

+36-36
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
#define idx_2(LUT, i1, i0) (idx_1(LUT, i0) + (LUT)[1][i1])
88
#define min(x, y) (((x) > (y)) ? (y) : (x))
99
#define unlikely(x) __builtin_expect(!!(x), 0)
10-
#define PUSH_SOLUTION(current_solution) \
11-
{ \
12-
packVectors_of_solution[current_solution_index] = current_solution; \
13-
current_solution_index++; \
14-
if (current_solution_index == 1) { \
15-
if (testSolution(wrapper_state_ptr, current_solution_index, packVectors_of_solution)) { \
16-
return; \
17-
} \
18-
current_solution_index = 0; \
19-
} \
10+
#define PUSH_SOLUTION(current_solution) \
11+
{ \
12+
packVectors_of_solution[current_solution_index] = current_solution; \
13+
current_solution_index++; \
14+
if (current_solution_index == 1) { \
15+
if (testSolution(States, current_solution_index, packVectors_of_solution)) { \
16+
return; \
17+
} \
18+
current_solution_index = 0; \
19+
} \
2020
}
2121
#define CHECK_SOLUTIONS() \
2222
{ \
@@ -105,7 +105,7 @@ static PackedVectors packVectors(int n, const Vector v);
105105
static uint64_t encodeToGray(uint64_t i);
106106
static int selectOneBit(uint64_t startPointHigh, uint64_t startPointLow, int index);
107107
static void freeEqs(int ***Eqs, int i, int j);
108-
static int initEqs(int n, int e, int ****EqsPtr);
108+
static int initEqs(int n, int e, int ****Eqs);
109109
static void convert1DTo3D(int n, int e, const uint8_t *coefficientsMatrix, int ***Eqs);
110110
static void mergeSolution(Settings *p, uint64_t count, uint64_t *Sol);
111111
static TableWithSize *initTable(int n);
@@ -114,9 +114,9 @@ static void freeTable(const TableWithSize *tab);
114114
static void *exfesCalloc(size_t num, size_t size, size_t max_num_retries);
115115
static void computeNextSet(int n, int d, int *set);
116116
static int convert3DToPackedVectors(const int n, int from, int to, int ***coeffs, TableWithSize *idx_LUT, PackedVectors *F);
117-
static int testSolution(States *wrapper_state_ptr, uint64_t size, uint64_t *n_solutions);
117+
static int testSolution(States *States, uint64_t size, uint64_t *n_solutions);
118118
static int fes(const int n, int n_eqs, int ***coeffs, Settings *settings);
119-
static void primarySearch(Table LUT, int n, PackedVectors *F, States *wrapper_state_ptr);
119+
static void primarySearch(Table LUT, int n, PackedVectors *F, States *States);
120120

121121
int exfes(uint32_t numFixedVariables, uint32_t numVariables, uint32_t numEquations, uint64_t startPointHigh, uint64_t startPointLow, const uint8_t *coefficientsMatrix, bool (*shouldAbortNow)(void), uint64_t *solutionHigh, uint64_t *solutionLow)
122122
{
@@ -305,22 +305,22 @@ static void freeEqs(int ***Eqs, int i, int j)
305305
free(Eqs);
306306
}
307307

308-
static int initEqs(int n, int e, int ****EqsPtr)
308+
static int initEqs(int n, int e, int ****Eqs)
309309
{
310-
EqsPtr[0] = (int ***)exfesCalloc(e, sizeof(int **), 10);
311-
if (!EqsPtr[0]) {
310+
Eqs[0] = (int ***)exfesCalloc(e, sizeof(int **), 10);
311+
if (!Eqs[0]) {
312312
return -4;
313313
}
314314
for (int i = 0; i < e; i++) {
315-
EqsPtr[0][i] = (int **)exfesCalloc(3, sizeof(int *), 10);
316-
if (!EqsPtr[0][i]) {
317-
freeEqs(EqsPtr[0], i, -1);
315+
Eqs[0][i] = (int **)exfesCalloc(3, sizeof(int *), 10);
316+
if (!Eqs[0][i]) {
317+
freeEqs(Eqs[0], i, -1);
318318
return -4;
319319
}
320320
for (int j = 0; j < 3; j++) {
321-
EqsPtr[0][i][j] = (int *)exfesCalloc(binomials[n][j], sizeof(int), 10);
322-
if (!EqsPtr[0][i][j]) {
323-
freeEqs(EqsPtr[0], i, j);
321+
Eqs[0][i][j] = (int *)exfesCalloc(binomials[n][j], sizeof(int), 10);
322+
if (!Eqs[0][i][j]) {
323+
freeEqs(Eqs[0], i, j);
324324
return -4;
325325
}
326326
}
@@ -505,14 +505,14 @@ static int convert3DToPackedVectors(const int n, int from, int to, int ***coeffs
505505
return 0;
506506
}
507507

508-
static int testSolution(States *wrapper_state_ptr, uint64_t size, uint64_t *n_solutions)
508+
static int testSolution(States *States, uint64_t size, uint64_t *n_solutions)
509509
{
510510
for (uint64_t i = 0; i < size; i++) {
511511
uint64_t current_solution = n_solutions[i];
512512
int is_correct = 1;
513513
int j = 0;
514-
while (is_correct && j < wrapper_state_ptr->numBatches) {
515-
if (secondaryEvaluation(wrapper_state_ptr->tableWithSize->table, wrapper_state_ptr->numVariables, wrapper_state_ptr->packedVectors2D[j], current_solution) != 0) {
514+
while (is_correct && j < States->numBatches) {
515+
if (secondaryEvaluation(States->tableWithSize->table, States->numVariables, States->packedVectors2D[j], current_solution) != 0) {
516516
is_correct = 0;
517517
}
518518
j++;
@@ -521,7 +521,7 @@ static int testSolution(States *wrapper_state_ptr, uint64_t size, uint64_t *n_so
521521
int num_correct_solutions = 1;
522522
uint64_t corrects_solutions[1];
523523
corrects_solutions[0] = current_solution;
524-
mergeSolution(wrapper_state_ptr->settings, num_correct_solutions, corrects_solutions);
524+
mergeSolution(States->settings, num_correct_solutions, corrects_solutions);
525525
return 1;
526526
}
527527
}
@@ -579,13 +579,13 @@ static int fes(const int n, int n_eqs, int ***coeffs, Settings *settings)
579579
freeTable(idx_LUT);
580580
return -4;
581581
}
582-
States wrapper_state;
583-
wrapper_state.numVariables = n;
584-
wrapper_state.numBatches = numBatches - 1;
585-
wrapper_state.packedVectors2D = G;
586-
wrapper_state.tableWithSize = idx_LUT;
587-
wrapper_state.settings = settings;
588-
primarySearch(idx_LUT->table, n, F, &wrapper_state);
582+
States States;
583+
States.numVariables = n;
584+
States.numBatches = numBatches - 1;
585+
States.packedVectors2D = G;
586+
States.tableWithSize = idx_LUT;
587+
States.settings = settings;
588+
primarySearch(idx_LUT->table, n, F, &States);
589589
for (int i = numBatches - 1; i >= 1; i--) {
590590
free(G[i - 1]);
591591
}
@@ -595,9 +595,9 @@ static int fes(const int n, int n_eqs, int ***coeffs, Settings *settings)
595595
return 0;
596596
}
597597

598-
static void primarySearch(Table LUT, int n, PackedVectors *F, States *wrapper_state_ptr)
598+
static void primarySearch(Table LUT, int n, PackedVectors *F, States *States)
599599
{
600-
Settings *ctx = wrapper_state_ptr->settings;
600+
Settings *ctx = States->settings;
601601
for (int i0 = 1; i0 < n; i0++) {
602602
if (i0 != 0) {
603603
F[idx_1(LUT, i0)] ^= F[idx_2(LUT, i0 - 1, i0)];
@@ -1168,5 +1168,5 @@ static void primarySearch(Table LUT, int n, PackedVectors *F, States *wrapper_st
11681168
CHECK_SOLUTIONS();
11691169
}
11701170
}
1171-
testSolution(wrapper_state_ptr, current_solution_index, packVectors_of_solution);
1171+
testSolution(States, current_solution_index, packVectors_of_solution);
11721172
}

0 commit comments

Comments
 (0)