int cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata)

{



    CacheItem *it = NULL;



    g_assert(cache);

    g_assert(cache->page_cache);



    /* actual update of entry */

    it = cache_get_by_addr(cache, addr);



    /* allocate page */

    if (!it->it_data) {

        it->it_data = g_try_malloc(cache->page_size);

        if (!it->it_data) {

            DPRINTF("Error allocating page\n");

            return -1;

        }

        cache->num_items++;

    }



    memcpy(it->it_data, pdata, cache->page_size);



    it->it_age = ++cache->max_item_age;

    it->it_addr = addr;



    return 0;

}

int cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata)

{



    CacheItem *it = NULL;



    g_assert(cache);

    g_assert(cache->page_cache);



    

    it = cache_get_by_addr(cache, addr);



    

    if (!it->it_data) {

        it->it_data = g_try_malloc(cache->page_size);

        if (!it->it_data) {

            DPRINTF("Error allocating page\n");

            return -1;

        }

        cache->num_items++;

    }



    memcpy(it->it_data, pdata, cache->page_size);



    it->it_age = ++cache->max_item_age;

    it->it_addr = addr;



    return 0;

}

int cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata)
int FUNC_0(PageCache *VAR_0, uint64_t VAR_1, uint8_t *VAR_2)

{



    CacheItem *it = NULL;



    g_assert(VAR_0);

    g_assert(VAR_0->page_cache);



    

    it = cache_get_by_addr(VAR_0, VAR_1);



    

    if (!it->it_data) {

        it->it_data = g_try_malloc(VAR_0->page_size);

        if (!it->it_data) {

            DPRINTF("Error allocating page\n");

            return -1;

        }

        VAR_0->num_items++;

    }



    memcpy(it->it_data, VAR_2, VAR_0->page_size);



    it->it_age = ++VAR_0->max_item_age;

    it->it_addr = VAR_1;



    return 0;

}

int FUNC_0(PageCache *VAR_0, uint64_t VAR_1, uint8_t *VAR_2)
{ CacheItem *it = NULL; g_assert(VAR_0); g_assert(VAR_0->page_cache); it = cache_get_by_addr(VAR_0, VAR_1); if (!it->it_data) { it->it_data = g_try_malloc(VAR_0->page_size); if (!it->it_data) { DPRINTF("Error allocating page\n"); return -1; } VAR_0->num_items++; } memcpy(it->it_data, VAR_2, VAR_0->page_size); it->it_age = ++VAR_0->max_item_age; it->it_addr = VAR_1; return 0; }