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-03-27 15:44:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-03-27 15:56:54 +0300
commite22b870b4a4c02f762471744675f5b4d8a940304 (patch)
tree159170612d9e44e65934ff4e9e432980c4e1f9b2 /source/blender/blenloader/intern
parent3bca1ef26bcbd65f1a9063f2d073c92f83c79b70 (diff)
Cleanup: global undo (minor changes to internals)
- Get memory usage from MemFile instead of MEM API avoids possible invalid when threads alloc memory. - Use size_t instead of uint and uintptr_t to store size. - Rename UndoElem.str -> filename - Rename MemFileChunk.ident -> is_identical
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r--source/blender/blenloader/intern/undofile.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index c191e48a143..ffc7d7c83f5 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -43,6 +43,9 @@
#include "BLO_undofile.h"
+/* keep last */
+#include "BLI_strict_flags.h"
+
/* **************** support for memory-write, for undo buffers *************** */
/* not memfile itself */
@@ -51,8 +54,9 @@ void BLO_memfile_free(MemFile *memfile)
MemFileChunk *chunk;
while ((chunk = BLI_pophead(&memfile->chunks))) {
- if (chunk->ident == 0)
- MEM_freeN(chunk->buf);
+ if (chunk->is_identical == false) {
+ MEM_freeN((void *)chunk->buf);
+ }
MEM_freeN(chunk);
}
memfile->size = 0;
@@ -68,9 +72,9 @@ void BLO_memfile_merge(MemFile *first, MemFile *second)
sc = second->chunks.first;
while (fc || sc) {
if (fc && sc) {
- if (sc->ident) {
- sc->ident = 0;
- fc->ident = 1;
+ if (sc->is_identical) {
+ sc->is_identical = false;
+ fc->is_identical = true;
}
}
if (fc) fc = fc->next;
@@ -98,7 +102,7 @@ void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsi
curchunk = MEM_mallocN(sizeof(MemFileChunk), "MemFileChunk");
curchunk->size = size;
curchunk->buf = NULL;
- curchunk->ident = 0;
+ curchunk->is_identical = false;
BLI_addtail(&current->chunks, curchunk);
/* we compare compchunk with buf */
@@ -106,17 +110,17 @@ void memfile_chunk_add(MemFile *compare, MemFile *current, const char *buf, unsi
if (compchunk->size == curchunk->size) {
if (memcmp(compchunk->buf, buf, size) == 0) {
curchunk->buf = compchunk->buf;
- curchunk->ident = 1;
+ curchunk->is_identical = true;
}
}
compchunk = compchunk->next;
}
-
+
/* not equal... */
if (curchunk->buf == NULL) {
- curchunk->buf = MEM_mallocN(size, "Chunk buffer");
- memcpy(curchunk->buf, buf, size);
+ char *buf_new = MEM_mallocN(size, "Chunk buffer");
+ memcpy(buf_new, buf, size);
+ curchunk->buf = buf_new;
current->size += size;
}
}
-