shada: Merge changes regardless whether they are from current instance

This commit is contained in:
ZyX
2015-08-11 01:28:05 +03:00
parent fcb3e96cbd
commit 0a334f9d33

View File

@@ -394,7 +394,6 @@ typedef struct {
ShadaEntry *additional_marks; ///< All marks with unknown names. ShadaEntry *additional_marks; ///< All marks with unknown names.
size_t additional_marks_size; ///< Size of the additional_marks array. size_t additional_marks_size; ///< Size of the additional_marks array.
Timestamp greatest_timestamp; ///< Greatest timestamp among marks. Timestamp greatest_timestamp; ///< Greatest timestamp among marks.
bool is_local_entry; ///< True if structure comes from the current session.
} FileMarks; } FileMarks;
KHASH_MAP_INIT_STR(file_marks, FileMarks) KHASH_MAP_INIT_STR(file_marks, FileMarks)
@@ -2506,7 +2505,6 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
kh_key(&wms->file_marks, k) = xstrdup(fname); kh_key(&wms->file_marks, k) = xstrdup(fname);
memset(filemarks, 0, sizeof(*filemarks)); memset(filemarks, 0, sizeof(*filemarks));
} }
filemarks->is_local_entry = true;
do { do {
fmark_T fm; fmark_T fm;
char name; char name;
@@ -2700,9 +2698,6 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
} else { } else {
COMPARE_WITH_ENTRY(&filemarks->marks[idx], entry); COMPARE_WITH_ENTRY(&filemarks->marks[idx], entry);
} }
} else {
if (filemarks->is_local_entry) {
shada_free_shada_entry(&entry);
} else { } else {
const int cl_len = (int) filemarks->changes_size; const int cl_len = (int) filemarks->changes_size;
int i; int i;
@@ -2723,15 +2718,18 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
} }
memmove(&filemarks->changes[0], &filemarks->changes[1], memmove(&filemarks->changes[0], &filemarks->changes[1],
sizeof(filemarks->changes[0]) * (size_t) i); sizeof(filemarks->changes[0]) * (size_t) i);
} else {
memmove(&filemarks->changes[i + 1], &filemarks->changes[i],
sizeof(filemarks->changes[0]) * (size_t) (cl_len - i));
}
} else if (i == 0) { } else if (i == 0) {
if (cl_len == JUMPLISTSIZE) { if (cl_len == JUMPLISTSIZE) {
i = -1; i = -1;
} else { } else if (cl_len > 0) {
memmove(&filemarks->changes[1], &filemarks->changes[0], memmove(&filemarks->changes[1], &filemarks->changes[0],
sizeof(filemarks->changes[0]) * (size_t) cl_len); sizeof(filemarks->changes[0]) * (size_t) cl_len);
} }
} }
}
if (i != -1) { if (i != -1) {
filemarks->changes[i] = (PossiblyFreedShadaEntry) { filemarks->changes[i] = (PossiblyFreedShadaEntry) {
.can_free_entry = true, .can_free_entry = true,
@@ -2744,7 +2742,6 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
shada_free_shada_entry(&entry); shada_free_shada_entry(&entry);
} }
} }
}
break; break;
} }
case kSDItemJump: { case kSDItemJump: {