Exemple #1
0
void memory_sub_session::deallocate(byte* p, size_t bytes)
{
    if (is_small_alloc(p))
    {
        // removing chunk
        remove_small_alloc(p);

        std::pair<byte*, std::pair<size_t, int> > chunk_alloc = free_small_chunk_alloc(p);
        std::pair<byte*, size_t> remainder = add_merge_remove_free_small_chunk(p, bytes);

        if (chunk_alloc.second.first == remainder.second)
        {
            if (munmap(chunk_alloc.first, chunk_alloc.second.first))
                LOG(WARN, "unmap error\n");

            remove_alloc(chunk_alloc.first);
        }
        else
        {
            add_free_small_chunk(remainder.first, remainder.second);
        }
    }
    else
    {
        if (munmap(reinterpret_cast<void*> (p), bytes))
            LOG(WARN, "unmap error\n");

        remove_alloc(p);
    }
}
Exemple #2
0
static void __free(void *vaddr, bool unmap)
{
	struct alloc *node = find_alloc((unsigned long)vaddr);

	if (!node)
		return;

#ifndef CONFIG_UML
	if (unmap)
		/*
		 * We need the double cast because otherwise gcc complains about
		 * cast to pointer of different size. This is technically a down
		 * cast but if unmap is being called, this had better be an
		 * actual 32-bit pointer anyway.
		 */
		iounmap((void *)(unsigned long)node->vaddr);
#endif


	gen_pool_free(node->mpool->gpool, node->paddr, node->len);
	node->mpool->free += node->len;

	remove_alloc(node);
	kfree(node);
}
Exemple #3
0
static void __free(void *vaddr, bool unmap)
{
	struct alloc *node = find_alloc(vaddr);

	if (!node)
		return;

	if (unmap)
		iounmap(node->vaddr);

	gen_pool_free(node->mpool->gpool, node->paddr, node->len);
	node->mpool->free += node->len;

	remove_alloc(node);
	kfree(node);
}