MCPcopy Create free account
hub / github.com/F-Stack/f-stack / malloc_domainset_aligned

Function malloc_domainset_aligned

freebsd/kern/kern_malloc.c:766–795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764}
765
766void *
767malloc_domainset_aligned(size_t size, size_t align,
768 struct malloc_type *mtp, struct domainset *ds, int flags)
769{
770 void *res;
771 size_t asize;
772
773 KASSERT(align != 0 && powerof2(align),
774 ("malloc_domainset_aligned: wrong align %#zx size %#zx",
775 align, size));
776 KASSERT(align <= PAGE_SIZE,
777 ("malloc_domainset_aligned: align %#zx (size %#zx) too large",
778 align, size));
779
780 /*
781 * Round the allocation size up to the next power of 2,
782 * because we can only guarantee alignment for
783 * power-of-2-sized allocations. Further increase the
784 * allocation size to align if the rounded size is less than
785 * align, since malloc zones provide alignment equal to their
786 * size.
787 */
788 asize = size <= align ? align : 1UL << flsl(size - 1);
789
790 res = malloc_domainset(asize, mtp, ds, flags);
791 KASSERT(res == NULL || ((uintptr_t)res & (align - 1)) == 0,
792 ("malloc_domainset_aligned: result not aligned %p size %#zx "
793 "allocsize %#zx align %#zx", res, size, asize, align));
794 return (res);
795}
796
797void *
798mallocarray(size_t nmemb, size_t size, struct malloc_type *type, int flags)

Callers 1

bounce_bus_dmamem_allocFunction · 0.85

Calls 2

malloc_domainsetFunction · 0.70
flslFunction · 0.50

Tested by

no test coverage detected