static void memory_cache_entry_free (gpointer data) { memory_cache_entry_t entry = (memory_cache_entry_t) data; if (entry){ release_data_callback(entry->data, entry->length); free(entry); } }
static void *validate_and_return_data (vmi_instance_t vmi, memory_cache_entry_t entry) { time_t now = time(NULL); if (vmi->memory_cache_age && (now - entry->last_updated > vmi->memory_cache_age)){ dbprint("--MEMORY cache refresh 0x%llx\n", entry->paddr); release_data_callback(entry->data, entry->length); entry->data = get_memory_data(vmi, entry->paddr, entry->length); entry->last_updated = now; gint64 *key = safe_malloc(sizeof(gint64)); *key = entry->paddr; vmi->memory_cache_lru = g_list_remove(vmi->memory_cache_lru, key); vmi->memory_cache_lru = g_list_prepend(vmi->memory_cache_lru, key); } entry->last_used = now; return entry->data; }
static void * validate_and_return_data( vmi_instance_t vmi, memory_cache_entry_t entry) { time_t now = time(NULL); if (vmi->memory_cache_age && (now - entry->last_updated > vmi->memory_cache_age)) { dbprint("--MEMORY cache refresh 0x%"PRIx64"\n", entry->paddr); release_data_callback(entry->data, entry->length); entry->data = get_memory_data(vmi, entry->paddr, entry->length); entry->last_updated = now; GList* lru_entry = g_list_find_custom(vmi->memory_cache_lru, &entry->paddr, g_int64_equal); vmi->memory_cache_lru = g_list_remove_link(vmi->memory_cache_lru, lru_entry); vmi->memory_cache_lru = g_list_concat(lru_entry, vmi->memory_cache_lru); } entry->last_used = now; return entry->data; }