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: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Benoît Canet <benoit@irqsave.net>
This commit is contained in:
parent
355ef4ac95
commit
e5354657a6
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user