altos/lisp: Add incremental collection
[fw/altos] / src / test / ao_lisp_test.c
index 41dae07aabf3d9155d331c63125d40e8961f245e..720355d2c99d734243a91c5fce547241c16fd3e1 100644 (file)
@@ -34,6 +34,24 @@ ao_lisp_os_save(void)
        return 1;
 }
 
+int
+ao_lisp_os_restore_save(struct ao_lisp_os_save *save, int offset)
+{
+       FILE    *restore = fopen(save_file, "r");
+       size_t  ret;
+
+       if (!restore) {
+               perror(save_file);
+               return 0;
+       }
+       fseek(restore, offset, SEEK_SET);
+       ret = fread(save, sizeof (struct ao_lisp_os_save), 1, restore);
+       fclose(restore);
+       if (ret != 1)
+               return 0;
+       return 1;
+}
+
 int
 ao_lisp_os_restore(void)
 {
@@ -83,4 +101,10 @@ main (int argc, char **argv)
                ao_lisp_file = NULL;
        }
        ao_lisp_read_eval_print();
+       printf ("collects: full: %d incremental %d\n",
+               ao_lisp_collects[AO_LISP_COLLECT_FULL],
+               ao_lisp_collects[AO_LISP_COLLECT_INCREMENTAL]);
+       printf ("freed: full %d incremental %d\n",
+               ao_lisp_freed[AO_LISP_COLLECT_FULL],
+               ao_lisp_freed[AO_LISP_COLLECT_INCREMENTAL]);
 }