aboutsummaryrefslogtreecommitdiff
path: root/page_cache.c
diff options
context:
space:
mode:
authorPeter Lieven <pl@dlhnet.de>2013-02-25 19:12:04 +0200
committerJuan Quintela <quintela@redhat.com>2013-03-11 13:32:03 +0100
commitee0b44aa9d9450e873a761ca2030b2fa3ec52eb0 (patch)
tree1f8f203f961610e5b5a1d23e8985df071e847d1b /page_cache.c
parent32a1c08b60a8ac0e63b54a5793a26b5e32b36618 (diff)
downloadqemu-ee0b44aa9d9450e873a761ca2030b2fa3ec52eb0.zip
qemu-ee0b44aa9d9450e873a761ca2030b2fa3ec52eb0.tar.gz
qemu-ee0b44aa9d9450e873a761ca2030b2fa3ec52eb0.tar.bz2
page_cache: dup memory on insert
The page cache frees all data on finish, on resize and if there is collision on insert. So it should be the caches responsibility to dup the data that is stored in the cache. Signed-off-by: Peter Lieven <pl@kamp.de> Signed-off-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'page_cache.c')
-rw-r--r--page_cache.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/page_cache.c b/page_cache.c
index 809dadc..938a79c 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -159,7 +159,7 @@ void cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata)
cache->num_items++;
}
- it->it_data = pdata;
+ it->it_data = g_memdup(pdata, cache->page_size);
it->it_age = ++cache->max_item_age;
it->it_addr = addr;
}