Commits

Shlomi Fish  committed 94e9623

More consting and just-in-time declarations.

  • Participants
  • Parent commits 03c0d66

Comments (0)

Files changed (2)

File fc-solve/source/check_and_add_state.c

     register fcs_state_t * const new_state_key = new_state->key;
     register fcs_state_extra_info_t * const new_state_info = new_state->val;
 
-    fcs_compact_allocator_t * stacks_allocator = &(hard_thread->allocator);
+    fcs_compact_allocator_t * const stacks_allocator = &(hard_thread->allocator);
 
     fcs_cards_column_t * current_stack = new_state_key->stacks;
 
 
 #define ON_STATE_NEW() on_state_new(instance, hard_thread, new_state->val);
 
-#if (FCS_STATE_STORAGE == FCS_STATE_STORAGE_INDIRECT)
-    fcs_standalone_state_ptrs_t * pos_ptr;
-    fcs_bool_t found;
-#endif
-    fc_solve_instance_t * instance = hard_thread->instance;
+    fc_solve_instance_t * const instance = hard_thread->instance;
 
     /* #if'ing out because it doesn't belong here. */
 #if 0
         }
     }
 #elif (FCS_STATE_STORAGE == FCS_STATE_STORAGE_INDIRECT)
+    fcs_standalone_state_ptrs_t * pos_ptr;
     /* Try to see if the state is found in indirect_prev_states */
     if ((pos_ptr = (fcs_standalone_state_ptrs_t *)bsearch(&new_state_key,
                 instance->indirect_prev_states,
                 sizeof(instance->indirect_prev_states[0]),
                 fc_solve_state_compare_indirect)) == NULL)
     {
+        fcs_bool_t found;
         /* It isn't in prev_states, but maybe it's in the sort margin */
         pos_ptr = (fcs_standalone_state_ptrs_t *)fc_solve_bsearch(
             &new_state_key,

File fc-solve/source/cmd_line.c

 
 #include "prefix.h"
 #include "inline.h"
+#include "bool.h"
 
 #include "cmd_line_enum.h"
 
     int ret_code = 1;
     char * home_dir_presetrc = NULL, * env_var_presetrc = NULL;
     const char * global_presetrc = NULL;
-    const char * path;
     const char * * presetrc_pathes[5];
-    int path_idx;
-    char line[8192];
     FILE * f = NULL;
     char * opened_files_dir = NULL;
-    int read_next_preset = 0;
 
 
     {
 
     global_presetrc = (FREECELL_SOLVER_PKG_DATA_DIR "/presetrc");
 
-    for(path_idx=0;(presetrc_pathes[path_idx] != NULL) ; path_idx++)
+    const char * path;
+    fcs_bool_t read_next_preset = FALSE;
+    for (int path_idx=0;(presetrc_pathes[path_idx] != NULL) ; path_idx++)
     {
         path = (*presetrc_pathes[path_idx]);
         if (path == NULL)
         }
         while(1)
         {
+            char line[8192];
             if (fgets(line, sizeof(line), f) == NULL)
             {
                 break;
                 nullify_newline();
                 if (!strcmp(line+5, preset_name))
                 {
-                    read_next_preset = 1;
+                    read_next_preset = TRUE;
                 }
             }
             else if (!strncmp(line, "command=", 8))
     freecell_solver_str_t opened_files_dir
     )
 {
-    freecell_solver_str_t * arg;
-    freecell_solver_str_t * arg_argc;
-    freecell_solver_str_t * known_param;
     int num_to_skip;
-    int callback_ret;
-    int opt;
     const char * p;
 
     *error_string = NULL;
 
-    arg_argc = &(argv[argc]);
+    freecell_solver_str_t * arg_argc = &(argv[argc]);
 
-    for(arg=&(argv[start_arg]);arg<arg_argc;arg++)
+    freecell_solver_str_t * arg;
+    freecell_solver_str_t * known_param;
+    for (arg = &(argv[start_arg]) ; arg < arg_argc ; arg++)
     {
         /* First check for the parameters that the user recognizes */
         known_param = known_parameters;
         {
             int ret;
 
-            callback_ret = callback(instance, argc, argv, arg-&(argv[0]), &num_to_skip, &ret, callback_context);
+            const int callback_ret = callback(instance, argc, argv, arg-&(argv[0]), &num_to_skip, &ret, callback_context);
             if (callback_ret == FCS_CMD_LINE_SKIP)
             {
                 arg += num_to_skip-1;
             }
         }
 
+        int opt;
         /* OPT-PARSE-START */
 p = (*arg);
 opt = FCS_OPT_UNRECOGNIZED;