Commits

Shlomi Fish  committed cc6decc

Implement a recycle function for the meta_alloc.

Now we have to implement it in libfreecell-solver.

  • Participants
  • Parent commits 150505f

Comments (0)

Files changed (2)

File fc-solve/source/meta_alloc.c

     fcs_meta_compact_allocator_t * meta_allocator
     )
 {
-    allocator->old_list = NULL;
     allocator->meta = meta_allocator;
 
-    fc_solve_compact_allocator_extend(allocator);
+    fc_solve_compact_allocator_init_helper(allocator);
+
     return;
 }
 
     OLD_LIST_NEXT(iter) = meta->recycle_bin;
     meta->recycle_bin = iter;
 }
+
 #undef OLD_LIST_NEXT
 #undef OLD_LIST_DATA

File fc-solve/source/meta_alloc.h

     fcs_meta_compact_allocator_t * meta;
 } fcs_compact_allocator_t;
 
+extern void fc_solve_compact_allocator_extend(
+    fcs_compact_allocator_t * allocator
+        );
+
+/* To be called after the meta_alloc was set. */
+static GCC_INLINE void fc_solve_compact_allocator_init_helper(
+    fcs_compact_allocator_t * allocator
+)
+{
+    allocator->old_list = NULL;
+    fc_solve_compact_allocator_extend(allocator);
+}
+
 static GCC_INLINE void fc_solve_meta_compact_allocator_init(
     fcs_meta_compact_allocator_t * meta
     )
     fcs_meta_compact_allocator_t * meta_allocator
     );
 
-extern void fc_solve_compact_allocator_extend(
-    fcs_compact_allocator_t * allocator
-        );
 
 static GCC_INLINE void * fcs_compact_alloc_ptr(fcs_compact_allocator_t * allocator, int how_much)
 {
     }
 }
 
+static GCC_INLINE void fc_solve_compact_allocator_recycle(fcs_compact_allocator_t * allocator)
+{
+    fc_solve_compact_allocator_finish(allocator);
+    fc_solve_compact_allocator_init_helper(allocator);
+}
+
 #ifdef __cplusplus
 };
 #endif