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:
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r--source/blender/blenloader/intern/writefile.c89
1 files changed, 40 insertions, 49 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 217162a67dc..e8bbc5ef36b 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -366,26 +366,31 @@ static void writedata_free(WriteData *wd)
/***/
/**
+ * Flush helps the de-duplicating memory for undo-save by logically segmenting data,
+ * so differences in one part of memory won't cause unrelated data to be duplicated.
+ */
+static void mywrite_flush(WriteData *wd)
+{
+ if (wd->count) {
+ writedata_do_write(wd, wd->buf, wd->count);
+ wd->count = 0;
+ }
+}
+
+/**
* Low level WRITE(2) wrapper that buffers data
* \param adr Pointer to new chunk of data
* \param len Length of new chunk of data
* \warning Talks to other functions with global parameters
*/
-
-#define MYWRITE_FLUSH NULL
-
static void mywrite(WriteData *wd, const void *adr, int len)
{
if (UNLIKELY(wd->error)) {
return;
}
- /* flush helps compression for undo-save */
- if (adr == MYWRITE_FLUSH) {
- if (wd->count) {
- writedata_do_write(wd, wd->buf, wd->count);
- wd->count = 0;
- }
+ if (adr == NULL) {
+ BLI_assert(0);
return;
}
@@ -816,8 +821,7 @@ static void write_actions(WriteData *wd, ListBase *idbase)
}
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_keyingsets(WriteData *wd, ListBase *list)
@@ -1894,8 +1898,7 @@ static void write_objects(WriteData *wd, ListBase *idbase)
ob = ob->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
@@ -1923,8 +1926,7 @@ static void write_vfonts(WriteData *wd, ListBase *idbase)
vf = vf->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
@@ -1957,8 +1959,8 @@ static void write_keys(WriteData *wd, ListBase *idbase)
key = key->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+
+ mywrite_flush(wd);
}
static void write_cameras(WriteData *wd, ListBase *idbase)
@@ -2060,8 +2062,7 @@ static void write_curves(WriteData *wd, ListBase *idbase)
cu = cu->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_dverts(WriteData *wd, int count, MDeformVert *dvlist)
@@ -2335,6 +2336,8 @@ static void write_meshes(WriteData *wd, ListBase *idbase)
mesh = mesh->id.next;
}
+
+ mywrite_flush(wd);
}
static void write_lattices(WriteData *wd, ListBase *idbase)
@@ -2362,8 +2365,7 @@ static void write_lattices(WriteData *wd, ListBase *idbase)
lt = lt->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_images(WriteData *wd, ListBase *idbase)
@@ -2407,8 +2409,8 @@ static void write_images(WriteData *wd, ListBase *idbase)
}
ima = ima->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+
+ mywrite_flush(wd);
}
static void write_textures(WriteData *wd, ListBase *idbase)
@@ -2460,8 +2462,7 @@ static void write_textures(WriteData *wd, ListBase *idbase)
tex = tex->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_materials(WriteData *wd, ListBase *idbase)
@@ -2578,8 +2579,7 @@ static void write_lamps(WriteData *wd, ListBase *idbase)
la = la->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_sequence_modifiers(WriteData *wd, ListBase *modbase)
@@ -2827,8 +2827,8 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
sce = sce->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+
+ mywrite_flush(wd);
}
static void write_gpencils(WriteData *wd, ListBase *lb)
@@ -2866,8 +2866,7 @@ static void write_gpencils(WriteData *wd, ListBase *lb)
}
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_windowmanagers(WriteData *wd, ListBase *lb)
@@ -3143,8 +3142,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
sc = sc->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_bone(WriteData *wd, Bone *bone)
@@ -3192,8 +3190,7 @@ static void write_armatures(WriteData *wd, ListBase *idbase)
arm = arm->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_texts(WriteData *wd, ListBase *idbase)
@@ -3234,8 +3231,7 @@ static void write_texts(WriteData *wd, ListBase *idbase)
text = text->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_speakers(WriteData *wd, ListBase *idbase)
@@ -3279,8 +3275,7 @@ static void write_sounds(WriteData *wd, ListBase *idbase)
sound = sound->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_groups(WriteData *wd, ListBase *idbase)
@@ -3304,8 +3299,7 @@ static void write_groups(WriteData *wd, ListBase *idbase)
}
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_nodetrees(WriteData *wd, ListBase *idbase)
@@ -3518,8 +3512,7 @@ static void write_movieclips(WriteData *wd, ListBase *idbase)
clip = clip->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_masks(WriteData *wd, ListBase *idbase)
@@ -3579,8 +3572,7 @@ static void write_masks(WriteData *wd, ListBase *idbase)
mask = mask->id.next;
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
static void write_linestyle_color_modifiers(WriteData *wd, ListBase *modifiers)
@@ -3930,8 +3922,7 @@ static void write_libraries(WriteData *wd, Main *main)
}
}
- /* flush helps the compression for undo-save */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
}
/* context is usually defined by WM, two cases where no WM is available:
@@ -4033,7 +4024,7 @@ static bool write_file_handle(
/* The windowmanager and screen often change,
* avoid thumbnail detecting changes because of this. */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
write_windowmanagers(wd, &mainvar->wm);
write_screens(wd, &mainvar->screen);
@@ -4069,7 +4060,7 @@ static bool write_file_handle(
write_libraries(wd, mainvar->next);
/* So changes above don't cause a 'DNA1' to be detected as changed on undo. */
- mywrite(wd, MYWRITE_FLUSH, 0);
+ mywrite_flush(wd);
if (write_flags & G_FILE_USERPREFS) {
write_userdef(wd);