Commit e5354657 authored by Kevin Wolf's avatar Kevin Wolf

qemu_memalign: Allow small alignments

The functions used by qemu_memalign() require an alignment that is at
least sizeof(void*). Adjust it if it is too small.
Signed-off-by: default avatarKevin Wolf <>
Reviewed-by: default avatarWenchao Xia <>
Reviewed-by: default avatarMax Reitz <>
Reviewed-by: default avatarBenoît Canet <>
parent 355ef4ac
......@@ -88,6 +88,11 @@ void *qemu_oom_check(void *ptr)
void *qemu_memalign(size_t alignment, size_t size)
void *ptr;
if (alignment < sizeof(void*)) {
alignment = sizeof(void*);
#if defined(_POSIX_C_SOURCE) && !defined(__sun__)
int ret;
ret = posix_memalign(&ptr, alignment, size);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment