Commits

Shlomi Fish committed c3e154f

Convert ptr_state_key in scans.c to "fcs_state_t state_key".

This is to make sure it won't get removed from the cache during long cache
lookups. This crashed the 2-deals freecell run on deal #982.

git-svn-id: file:///home/shlomif/Backup/svn-dumps/google-code/svnsync-repos/fc-solve/branches/rcs-states-storage@3230 e7e8a897-7ba4-4ee7-b36f-f4c66519b19a

  • Participants
  • Parent commits 328cf16
  • Branches rcs-states-storage, rcs-states-storage@3680

Comments (0)

Files changed (1)

fc-solve/source/scans.c

     by using some dedicated stacks for the traversal.
   */
 #ifdef FCS_RCS_STATES
-#define the_state (*ptr_state_key)
+#define the_state (state_key)
 #else
 #define the_state (ptr_state->s)
 #endif
 
 #endif
 
+#define ASSIGN_STATE_KEY() (state_key = (*(fc_solve_lookup_state_key_from_val(instance, ptr_state))))
+
 int fc_solve_soft_dfs_do_solve(
     fc_solve_soft_thread_t * soft_thread
     )
     fc_solve_instance_t * instance = hard_thread->instance;
 
 #ifdef FCS_RCS_STATES
-    fcs_state_t * ptr_state_key;
+    fcs_state_t state_key;
 #endif
     fcs_collectible_state_t * ptr_state;
     fcs_soft_dfs_stack_item_t * the_soft_dfs_info;
     derived_states_list = &(the_soft_dfs_info->derived_states_list);
     
 #ifdef FCS_RCS_STATES
-    ptr_state_key = fc_solve_lookup_state_key_from_val(instance, ptr_state);
+    ASSIGN_STATE_KEY();
 #endif
 
     rand_gen = &(soft_thread->method_specific.soft_dfs.rand_gen);
                     ptr_state = the_soft_dfs_info->state;
  
 #ifdef FCS_RCS_STATES
-                    ptr_state_key = fc_solve_lookup_state_key_from_val(instance, ptr_state);
+                    ASSIGN_STATE_KEY();
 #endif
 
                     soft_thread->num_vacant_freecells = the_soft_dfs_info->num_vacant_freecells;
                         soft_thread->method_specific.soft_dfs.depth,
                         (void*)instance,
 #ifdef FCS_RCS_STATES
-                        ptr_state_key,
+                        &(state_key),
 #endif
                         ptr_state,
                         ((soft_thread->method_specific.soft_dfs.depth == 0) ?
                     if (fc_solve_sfs_raymond_prune(
                         soft_thread, 
 #ifdef FCS_RCS_STATES
-                        ptr_state_key,
+                        &(state_key),
 #endif
                         ptr_state, 
 #ifdef FCS_RCS_STATES
                     (
                         soft_thread,
 #ifdef FCS_RCS_STATES
-                        ptr_state_key,
+                        &(state_key),
 #endif
                         ptr_state,
                         derived_states_list
                         single_derived_state;
 
 #ifdef FCS_RCS_STATES
-                    ptr_state_key = fc_solve_lookup_state_key_from_val(instance, ptr_state);
+                    ASSIGN_STATE_KEY();
 #endif
                     
 
     fcs_collectible_state_t * ptr_state
     )
 {
+#ifdef FCS_RCS_STATES
+#define state_key (*ptr_state_key)
+#endif
 #ifndef FCS_FREECELL_ONLY
     fc_solve_hard_thread_t * hard_thread = soft_thread->hard_thread;
     fc_solve_instance_t * instance = hard_thread->instance;
 
     return (int)(ret*INT_MAX);
 }
+#ifdef FCS_RCS_STATES
+#undef state_key
+#endif
+
 
 #ifdef FCS_FREECELL_ONLY
 #undef unlimited_sequence_move
 
     fcs_collectible_state_t * ptr_state, * ptr_new_state;
 #ifdef FCS_RCS_STATES
-    fcs_state_t * ptr_state_key;
+    fcs_state_t state_key;
 #endif
     fcs_game_limit_t num_vacant_stacks, num_vacant_freecells;
     fcs_states_linked_list_item_t * save_item;
         TRACE0("Start of loop");
 
 #ifdef FCS_RCS_STATES
-        ptr_state_key = fc_solve_lookup_state_key_from_val(instance, ptr_state);
+        ASSIGN_STATE_KEY();
 #endif
         
 #ifdef DEBUG
             if (fc_solve_sfs_raymond_prune(
                     soft_thread,
 #ifdef FCS_RCS_STATES
-                    ptr_state_key,
+                    (&state_key),
 #endif
                     ptr_state,
 #ifdef FCS_RCS_STATES
                 ptr_state = derived;
  
 #ifdef FCS_RCS_STATES
-                ptr_state_key = fc_solve_lookup_state_key_from_val(instance, ptr_state);
+                ASSIGN_STATE_KEY();
 #endif
                 
             }
                     FCS_S_DEPTH(ptr_state),
                     (void*)instance,
 #ifdef FCS_RCS_STATES
-                    ptr_state_key,
+                    (&state_key),
 #endif
                     ptr_state,
                     ((FCS_S_PARENT(ptr_state) == NULL) ?
             (*next_test)(
                 soft_thread,
 #ifdef FCS_RCS_STATES
-                ptr_state_key,
+                &(state_key),
 #endif
                 ptr_state,
                 &derived
         fcs_collectible_state_t * ptr_state
         )
 {
+#ifdef FCS_RCS_STATES
+#define state_key (*ptr_state_key)
+#endif
+
     char * * positions_by_rank_location;
     switch(soft_thread->method)
     {
 
     return *positions_by_rank_location;
 }
+#ifdef FCS_RCS_STATES
+#undef state_key
+#endif
 
 /* 
  * These functions are used by the move functions in freecell.c and