aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2022-02-27 16:53:22 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2022-02-27 16:53:22 +0100
commit7de88d1bcd420447023b8e74b0aa4f5e8ba1df6b (patch)
tree71458dbc99241c9d56744508996d68099bf01936 /src
parent48cd8b6b1779f34ba0507cb697492de83c4e9da8 (diff)
downloadnissy-7de88d1bcd420447023b8e74b0aa4f5e8ba1df6b.tar.gz
nissy-7de88d1bcd420447023b8e74b0aa4f5e8ba1df6b.zip
Removed array-size constants for certain objects (steps, commands...)
Diffstat (limited to '')
-rw-r--r--src/commands.c18
-rw-r--r--src/commands.h4
-rw-r--r--src/pruning.c3
-rw-r--r--src/pruning.h4
-rw-r--r--src/shell.c4
-rw-r--r--src/steps.c4
-rw-r--r--src/steps.h48
7 files changed, 20 insertions, 65 deletions
diff --git a/src/commands.c b/src/commands.c
index b397878..03eded0 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -150,7 +150,7 @@ version_cmd = {
150 .exec = version_exec, 150 .exec = version_exec,
151}; 151};
152 152
153Command *commands[NCOMMANDS] = { 153Command *commands[] = {
154 &commands_cmd, 154 &commands_cmd,
155 &gen_cmd, 155 &gen_cmd,
156 &help_cmd, 156 &help_cmd,
@@ -164,6 +164,7 @@ Command *commands[NCOMMANDS] = {
164 &cleanup_cmd, 164 &cleanup_cmd,
165 &unniss_cmd, 165 &unniss_cmd,
166 &version_cmd, 166 &version_cmd,
167 NULL
167}; 168};
168 169
169/* Other constants ***********************************************************/ 170/* Other constants ***********************************************************/
@@ -336,9 +337,8 @@ help_parse_args(int c, char **v)
336 CommandArgs *a = new_args(); 337 CommandArgs *a = new_args();
337 338
338 if (c == 1) { 339 if (c == 1) {
339 for (i = 0; i < NCOMMANDS; i++) 340 for (i = 0; commands[i] != NULL; i++)
340 if (commands[i] != NULL && 341 if (!strcmp(v[0], commands[i]->name))
341 !strcmp(v[0], commands[i]->name))
342 a->command = commands[i]; 342 a->command = commands[i];
343 if (a->command == NULL) 343 if (a->command == NULL)
344 fprintf(stderr, "%s: command not found\n", v[0]); 344 fprintf(stderr, "%s: command not found\n", v[0]);
@@ -473,7 +473,7 @@ gen_exec(CommandArgs *args)
473 init_symcoord(); 473 init_symcoord();
474 474
475 fprintf(stderr, "Generating pruning tables...\n"); 475 fprintf(stderr, "Generating pruning tables...\n");
476 for (i = 0; i < NPTABLES && allpd[i] != NULL; i++) 476 for (i = 0; allpd[i] != NULL; i++)
477 genptable(allpd[i], args->opts->nthreads); 477 genptable(allpd[i], args->opts->nthreads);
478 478
479 fprintf(stderr, "Done!\n"); 479 fprintf(stderr, "Done!\n");
@@ -495,7 +495,7 @@ steps_exec(CommandArgs *args)
495{ 495{
496 int i; 496 int i;
497 497
498 for (i = 0; i < NSTEPS && steps[i] != NULL; i++) 498 for (i = 0; steps[i] != NULL; i++)
499 printf("%-15s %s\n", steps[i]->shortname, steps[i]->name); 499 printf("%-15s %s\n", steps[i]->shortname, steps[i]->name);
500} 500}
501 501
@@ -504,7 +504,7 @@ commands_exec(CommandArgs *args)
504{ 504{
505 int i; 505 int i;
506 506
507 for (i = 0; i < NCOMMANDS && commands[i] != NULL; i++) 507 for (i = 0; commands[i] != NULL; i++)
508 printf("%s\n", commands[i]->usage); 508 printf("%s\n", commands[i]->usage);
509 509
510} 510}
@@ -642,8 +642,8 @@ read_step(CommandArgs *args, char *str)
642{ 642{
643 int i; 643 int i;
644 644
645 for (i = 0; i < NSTEPS; i++) { 645 for (i = 0; steps[i] != NULL; i++) {
646 if (steps[i] != NULL && !strcmp(steps[i]->shortname, str)) { 646 if (!strcmp(steps[i]->shortname, str)) {
647 args->step = steps[i]; 647 args->step = steps[i];
648 return true; 648 return true;
649 } 649 }
diff --git a/src/commands.h b/src/commands.h
index bac71f1..b7a4c36 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -6,11 +6,9 @@
6#include "solve.h" 6#include "solve.h"
7#include "steps.h" 7#include "steps.h"
8 8
9#define NCOMMANDS 20
10
11void free_args(CommandArgs *args); 9void free_args(CommandArgs *args);
12CommandArgs * new_args(); 10CommandArgs * new_args();
13 11
14extern Command * commands[NCOMMANDS]; 12extern Command * commands[];
15 13
16#endif 14#endif
diff --git a/src/pruning.c b/src/pruning.c
index e6fd791..51bea10 100644
--- a/src/pruning.c
+++ b/src/pruning.c
@@ -98,7 +98,7 @@ pd_nxopt31_HTM = {
98 .fbmod = BINOM8ON4, 98 .fbmod = BINOM8ON4,
99}; 99};
100 100
101PruneData * allpd[NPTABLES] = { 101PruneData * allpd[] = {
102 &pd_eofb_HTM, 102 &pd_eofb_HTM,
103 &pd_coud_HTM, 103 &pd_coud_HTM,
104 &pd_cornershtr_HTM, 104 &pd_cornershtr_HTM,
@@ -110,6 +110,7 @@ PruneData * allpd[NPTABLES] = {
110 &pd_htrfin_htr, 110 &pd_htrfin_htr,
111/* &pd_khuge_HTM,*/ 111/* &pd_khuge_HTM,*/
112 &pd_nxopt31_HTM, 112 &pd_nxopt31_HTM,
113 NULL
113}; 114};
114 115
115/* Functions *****************************************************************/ 116/* Functions *****************************************************************/
diff --git a/src/pruning.h b/src/pruning.h
index 0f20384..7da1e3e 100644
--- a/src/pruning.h
+++ b/src/pruning.h
@@ -3,8 +3,6 @@
3 3
4#include "symcoord.h" 4#include "symcoord.h"
5 5
6#define NPTABLES 20
7
8extern PruneData pd_eofb_HTM; 6extern PruneData pd_eofb_HTM;
9extern PruneData pd_coud_HTM; 7extern PruneData pd_coud_HTM;
10extern PruneData pd_corners_HTM; 8extern PruneData pd_corners_HTM;
@@ -17,7 +15,7 @@ extern PruneData pd_htrfin_htr;
17extern PruneData pd_khuge_HTM; 15extern PruneData pd_khuge_HTM;
18extern PruneData pd_nxopt31_HTM; 16extern PruneData pd_nxopt31_HTM;
19 17
20extern PruneData * allpd[NPTABLES]; 18extern PruneData * allpd[];
21 19
22void genptable(PruneData *pd, int nthreads); 20void genptable(PruneData *pd, int nthreads);
23void print_ptable(PruneData *pd); 21void print_ptable(PruneData *pd);
diff --git a/src/shell.c b/src/shell.c
index 2cb3719..6e67e0a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -37,8 +37,8 @@ exec_args(int c, char **v)
37 CommandArgs *args; 37 CommandArgs *args;
38 Alg *scramble; 38 Alg *scramble;
39 39
40 for (i = 0; i < NCOMMANDS; i++) 40 for (i = 0; commands[i] != NULL; i++)
41 if (commands[i] != NULL && !strcmp(v[0], commands[i]->name)) 41 if (!strcmp(v[0], commands[i]->name))
42 cmd = commands[i]; 42 cmd = commands[i];
43 43
44 if (cmd == NULL) { 44 if (cmd == NULL) {
diff --git a/src/steps.c b/src/steps.c
index 5de3206..83d105c 100644
--- a/src/steps.c
+++ b/src/steps.c
@@ -929,7 +929,7 @@ htrfin_htr = {
929 .ntables = 1, 929 .ntables = 1,
930}; 930};
931 931
932Step *steps[NSTEPS] = { 932Step *steps[] = {
933 &optimal_HTM, /* first is default */ 933 &optimal_HTM, /* first is default */
934 &optimal_light_HTM, 934 &optimal_light_HTM,
935 935
@@ -985,6 +985,8 @@ Step *steps[NSTEPS] = {
985 &cornershtr_URF, 985 &cornershtr_URF,
986 &corners_HTM, 986 &corners_HTM,
987 &corners_URF, 987 &corners_URF,
988
989 NULL
988}; 990};
989 991
990/* Checkers, estimators and validators ***************************************/ 992/* Checkers, estimators and validators ***************************************/
diff --git a/src/steps.h b/src/steps.h
index 53f8e1b..da5c041 100644
--- a/src/steps.h
+++ b/src/steps.h
@@ -3,55 +3,11 @@
3 3
4#include "pruning.h" 4#include "pruning.h"
5 5
6#define NSTEPS 50 6extern Step * steps[];
7 7
8extern Step * steps[NSTEPS]; 8/* Two steps used directly by two-phase solver */
9
10extern Step optimal_HTM;
11extern Step optimal_light_HTM;
12extern Step eofin_eo;
13extern Step eofbfin_eofb;
14extern Step eorlfin_eorl;
15extern Step eoudfin_eoud;
16extern Step eoany_HTM;
17extern Step eofb_HTM;
18extern Step eorl_HTM;
19extern Step eoud_HTM;
20extern Step coany_HTM;
21extern Step coud_HTM;
22extern Step corl_HTM;
23extern Step cofb_HTM;
24extern Step coany_URF;
25extern Step coud_URF;
26extern Step corl_URF;
27extern Step cofb_URF;
28extern Step drany_HTM; 9extern Step drany_HTM;
29extern Step drud_HTM;
30extern Step drrl_HTM;
31extern Step drfb_HTM;
32extern Step dr_eo;
33extern Step dr_eofb;
34extern Step dr_eorl;
35extern Step dr_eoud;
36extern Step drud_eofb;
37extern Step drrl_eofb;
38extern Step drud_eorl;
39extern Step drfb_eorl;
40extern Step drfb_eoud;
41extern Step drrl_eoud;
42extern Step dranyfin_DR; 10extern Step dranyfin_DR;
43extern Step drudfin_drud;
44extern Step drrlfin_drrl;
45extern Step drfbfin_drfb;
46extern Step htr_any;
47extern Step htr_drud;
48extern Step htr_drrl;
49extern Step htr_drfb;
50extern Step htrfin_htr;
51extern Step cornershtr_HTM;
52extern Step cornershtr_URF;
53extern Step corners_HTM;
54extern Step corners_URF;
55 11
56void copy_estimatedata(EstimateData *s, EstimateData *d); 12void copy_estimatedata(EstimateData *s, EstimateData *d);
57void invert_estimatedata(EstimateData *ed); 13void invert_estimatedata(EstimateData *ed);

Generated with cgit - Back to sebastiano.tronto.net