Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-04-14 13:33:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-04-14 14:03:41 +0300
commitcbd4a79c6d8bf479fc0914df29f8d367b232bb1a (patch)
tree76a0f29e2c41dd09d4ce5ceb3203bd4a1e2ac8bd /source/blender/blenloader/intern/undofile.c
parent2e9b92b5ccac07f63c1b535cfb25e013e01a141b (diff)
Undo: refactor memfile writing
- Move static undo variable into 'WriteData', 'memfile_chunk_add' used arguments in a confusing way, sometimes to set/clear static var. - Replace checks for 'wd->current' with 'wd->use_memfile' move memfile vars into 'wd->mem' struct.
Diffstat (limited to 'source/blender/blenloader/intern/undofile.c')
-rw-r--r--source/blender/blenloader/intern/undofile.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index f6584ecf25f..7133dee0e82 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -96,36 +96,26 @@ void BLO_memfile_merge(MemFile *first, MemFile *second)
BLO_memfile_free(first);
}
-void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsigned int size)
+void memfile_chunk_add(
+ MemFile *memfile, const char *buf, unsigned int size,
+ MemFileChunk **compchunk_step)
{
- static MemFileChunk *compchunk = NULL;
- MemFileChunk *curchunk;
-
- /* this function inits when compare != NULL or when current == NULL */
- if (compare) {
- compchunk = compare->chunks.first;
- return;
- }
- if (current == NULL) {
- compchunk = NULL;
- return;
- }
-
- curchunk = MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk");
+ MemFileChunk *curchunk = MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk");
curchunk->size = size;
curchunk->buf = NULL;
curchunk->is_identical = false;
- BLI_addtail(&current->chunks, curchunk);
-
+ BLI_addtail(&memfile->chunks, curchunk);
+
/* we compare compchunk with buf */
- if (compchunk) {
+ if (*compchunk_step != NULL) {
+ MemFileChunk *compchunk = *compchunk_step;
if (compchunk->size == curchunk->size) {
if (memcmp(compchunk->buf, buf, size) == 0) {
curchunk->buf = compchunk->buf;
curchunk->is_identical = true;
}
}
- compchunk = compchunk->next;
+ *compchunk_step = compchunk->next;
}
/* not equal... */
@@ -133,7 +123,7 @@ void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsi
char *buf_new = MEM_mallocN(size, "Chunk buffer");
memcpy(buf_new, buf, size);
curchunk->buf = buf_new;
- current->size += size;
+ memfile->size += size;
}
}