From 4cee8d9354092735ff79aa199b5aaddc355d978e Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sun, 27 May 2007 11:40:55 +0000 Subject: [PATCH] Prevent destroying dircache pointers in tagcache DB while updating runtime stats. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13498 a1c6a512-1295-4272-9138-f99709370657 --- apps/tagcache.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/tagcache.c b/apps/tagcache.c index 08e89eb5c6..d82149ad3b 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -547,9 +547,24 @@ static bool write_index(int masterfd, int idxid, struct index_entry *idx) } #ifdef HAVE_TC_RAMCACHE + /* Only update numeric data. Writing the whole index to RAM by memcpy + * destroys dircache pointers! + */ if (tc_stat.ramcache) { - memcpy(&hdr->indices[idxid], idx, sizeof(struct index_entry)); + int tag; + struct index_entry *idx_ram = &hdr->indices[idxid]; + + for (tag = 0; tag < TAG_COUNT; tag++) + { + if (tagcache_is_numeric_tag(tag)) + { + idx_ram->tag_seek[tag] = idx->tag_seek[tag]; + } + } + + /* Don't touch the dircache flag. */ + idx_ram->flag = idx->flag | (idx_ram->flag & FLAG_DIRCACHE); } #endif