updated contact info in source file headers
[rocksndiamonds.git] / src / libgame / snapshot.c
1 // ============================================================================
2 // Artsoft Retro-Game Library
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // snapshot.c
10 // ============================================================================
11
12 #include "snapshot.h"
13
14
15 static ListNode *engine_snapshot_list = NULL;
16
17 void SaveEngineSnapshotBuffer(void *buffer, int size)
18 {
19   struct EngineSnapshotNodeInfo *bi =
20     checked_calloc(sizeof(struct EngineSnapshotNodeInfo));
21
22   bi->buffer_orig = buffer;
23   bi->buffer_copy = checked_malloc(size);
24   bi->size = size;
25
26   memcpy(bi->buffer_copy, buffer, size);
27
28   addNodeToList(&engine_snapshot_list, NULL, bi);
29 }
30
31 static void LoadEngineSnapshotBuffer(struct EngineSnapshotNodeInfo *bi)
32 {
33   memcpy(bi->buffer_orig, bi->buffer_copy, bi->size);
34 }
35
36 void LoadEngineSnapshotBuffers()
37 {
38   ListNode *node = engine_snapshot_list;
39
40   while (node != NULL)
41   {
42     LoadEngineSnapshotBuffer((struct EngineSnapshotNodeInfo *)node->content);
43
44     node = node->next;
45   }
46 }
47
48 void FreeEngineSnapshotBuffers()
49 {
50   while (engine_snapshot_list != NULL)
51     deleteNodeFromList(&engine_snapshot_list, engine_snapshot_list->key,
52                        checked_free);
53 }