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
This commit is contained in:
parent
2ec4c3c7f3
commit
71d31f1cf6
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user