/* actual update of entry */
it = cache_get_by_addr(cache, addr);
+ /* free old cached data if any */
+ g_free(it->it_data);
+
if (!it->it_data) {
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;
}