Exemple #1
0
ucs_status_t uct_mem_free(const uct_allocated_memory_t *mem)
{
    int ret;

    switch (mem->method) {
    case UCT_ALLOC_METHOD_MD:
        return uct_md_mem_free(mem->md, mem->memh);

    case UCT_ALLOC_METHOD_HEAP:
        ucs_free(mem->address);
        return UCS_OK;

    case UCT_ALLOC_METHOD_MMAP:
        ret = ucs_munmap(mem->address, mem->length);
        if (ret != 0) {
            ucs_warn("munmap(address=%p, length=%zu) failed: %m", mem->address,
                     mem->length);
            return UCS_ERR_INVALID_PARAM;
        }
        return UCS_OK;

    case UCT_ALLOC_METHOD_HUGE:
        return ucs_sysv_free(mem->address);

    default:
        ucs_warn("Invalid memory allocation method: %d", mem->method);
        return UCS_ERR_INVALID_PARAM;
    }
}
Exemple #2
0
void ucs_mpool_chunk_munmap(ucs_mpool_t *mp, void *chunk)
{
    ucs_mmap_mpool_chunk_hdr_t *hdr = chunk;
    hdr -= 1;
    ucs_munmap(hdr, hdr->size);
}