diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-02-18 16:22:34 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-03-05 18:04:57 +0200 |
commit | bdc470a80e0260011e3dfc4d949df8f9e222f73f (patch) | |
tree | 625c26f2f754a56929d2f8880170c38b8f7d779b /core/load-git.c | |
parent | e5dcd9fc161891a4e70364e1dcdf232590eb49c6 (diff) | |
download | subsurface-bdc470a80e0260011e3dfc4d949df8f9e222f73f.tar.gz |
Cleanup: Remove hash field from picture-structure
The hash field in the picture-structure was in principle non-operational.
It was set on loading, but never actually changed. The authoritative
hash comes from the filename->hash map.
Therefore, make this explicit by removing the hash field from the
picture structure.
Instead of filling the picture structure on loading, add the
hash directly to the filename->hash map. This is done in the
register_hash() function, which does not overwrite old entries.
I.e. the local hash has priority over the save-file. This
policy might be refined in the future.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/load-git.c')
-rw-r--r-- | core/load-git.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/core/load-git.c b/core/load-git.c index cfb4a721b..d5a91d109 100644 --- a/core/load-git.c +++ b/core/load-git.c @@ -50,10 +50,13 @@ static void save_picture_from_git(struct picture *picture) struct picture_entry_list *pic_entry = pel; while (pic_entry) { - if (same_string(pic_entry->hash, picture->hash)) { - savePictureLocal(picture, pic_entry->data, pic_entry->len); + char *hash = hashstring(picture->filename); + if (same_string(pic_entry->hash, hash)) { + savePictureLocal(picture, hash, pic_entry->data, pic_entry->len); + free(hash); return; } + free(hash); pic_entry = pic_entry->next; } fprintf(stderr, "didn't find picture entry for %s\n", picture->filename); @@ -971,7 +974,9 @@ static void parse_picture_hash(char *line, struct membuffer *str, void *_pic) { (void) line; struct picture *pic = _pic; - pic->hash = get_utf8(str); + char *hash = get_utf8(str); + register_hash(pic->filename, get_utf8(str)); + free(hash); } /* These need to be sorted! */ |