+
+#if DEBUG_SNAPSHOTS
+ Debug("snapshot:ReduceSnapshotList",
+ "(Reducing number of snapshots from %d to %d.)",
+ num_snapshots_last, num_snapshots);
+
+#if 0
+ node = snapshot_list;
+ while (node)
+ {
+ Debug("snapshot:ReduceSnapshotList", "key: %s", node->key);
+
+ node = node->next;
+ }
+#endif
+#endif
+}
+
+void SaveSnapshotSingle(ListNode *snapshot_buffers)
+{
+ if (snapshot_single)
+ FreeSnapshotSingle();
+
+ snapshot_single = snapshot_buffers;
+}
+
+void SaveSnapshotToList(ListNode *snapshot_buffers)
+{
+ if (snapshot_current != snapshot_list)
+ FreeSnapshotList_UpToNode(snapshot_current);
+
+#if DEBUG_SNAPSHOTS
+ Debug("snapshot:SaveSnapshotToList",
+ "[%d] [%d snapshots, %d buffers, %d bytes]",
+ next_snapshot_key, num_snapshots,
+ num_snapshot_buffers, num_snapshot_bytes);
+#endif
+
+ addNodeToList(&snapshot_list, i_to_a(next_snapshot_key),
+ snapshot_buffers);
+
+ snapshot_current = snapshot_list;
+
+ num_snapshots++;
+ next_snapshot_key++;
+
+ if (num_snapshot_bytes > setup.engine_snapshot_memory)
+ ReduceSnapshotList();
+}
+
+boolean LoadSnapshotSingle(void)
+{
+ if (snapshot_single)
+ {
+ LoadSnapshotBuffers(snapshot_single);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+boolean LoadSnapshotFromList_Older(int steps)
+{
+ if (snapshot_current && snapshot_current->next)
+ {
+ while (snapshot_current->next && steps--)
+ snapshot_current = snapshot_current->next;
+
+ LoadSnapshotBuffers(snapshot_current->content);
+
+#if DEBUG_SNAPSHOTS
+ Debug("snapshot:LoadSnapshotFromList_Older", "[%s]", snapshot_current->key);
+#endif
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+boolean LoadSnapshotFromList_Newer(int steps)
+{
+ if (snapshot_current && snapshot_current->prev)
+ {
+ while (snapshot_current->prev && steps--)
+ snapshot_current = snapshot_current->prev;
+
+ LoadSnapshotBuffers(snapshot_current->content);
+
+#if DEBUG_SNAPSHOTS
+ Debug("snapshot:LoadSnapshotFromList_Newer", "[%s]", snapshot_current->key);
+#endif
+
+ return TRUE;
+ }
+
+ return FALSE;