void * uvalloc (umalloc_heap_t *md, uintptr_t size) { if (cache_pagesize == 0) { cache_pagesize = (uintptr_t) getpagesize(); } return (umemalign(md, cache_pagesize, size)); }
/*---------------------------------------------------------------------------*/ struct xio_buf *xio_alloc(size_t length) { struct xio_buf *buf; size_t real_size; int alloced = 0; buf = (struct xio_buf *)ucalloc(1, sizeof(*buf)); if (!buf) { xio_set_error(errno); ERROR_LOG("calloc failed. (errno=%d %m)\n", errno); return NULL; } real_size = ALIGN(length, page_size); buf->addr = umemalign(page_size, real_size); if (!buf->addr) { ERROR_LOG("xio_memalign failed. sz:%zu\n", real_size); goto cleanup; } memset(buf->addr, 0, real_size); alloced = 1; buf->mr = xio_reg_mr(&buf->addr, length); if (!buf->mr) { ERROR_LOG("xio_reg_mr failed. addr:%p, length:%d\n", buf->addr, length, access); goto cleanup1; } buf->length = length; return buf; cleanup1: if (alloced) ufree(buf->addr); cleanup: ufree(buf); return NULL; }