Commit 71d31f1c authored by Konstantin Belousov's avatar Konstantin Belousov
Browse files

malloc_aligned(9): allow zero size and alignment

For alignment we do not need to do anything to make it operational.
For size, upgrade zero sized request to one byte so that we do not
request insane amount of memory for placeholder.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32127
parent 2ec4c3c7
......@@ -797,7 +797,7 @@ malloc_domainset_aligned(size_t size, size_t align,
void *res;
size_t asize;
KASSERT(align != 0 && powerof2(align),
KASSERT(powerof2(align),
("malloc_domainset_aligned: wrong align %#zx size %#zx",
align, size));
KASSERT(align <= PAGE_SIZE,
......@@ -812,6 +812,8 @@ malloc_domainset_aligned(size_t size, size_t align,
* align, since malloc zones provide alignment equal to their
* size.
*/
if (size == 0)
size = 1;
asize = size <= align ? align : 1UL << flsl(size - 1);
res = malloc_domainset(asize, mtp, ds, flags);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment