diff options
author | Kevin Wolf <kwolf@redhat.com> | 2014-05-20 12:24:05 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-08-15 15:07:15 +0200 |
commit | 7d2a35cc921ea4832083a7e8598461868bb538ce (patch) | |
tree | 0aabab68f9ae59485bba04d9fe374ed0e603af1e /util/oslib-win32.c | |
parent | 23d20b5b4fb7bde102e6779b7a13b88375e4db66 (diff) |
block: Introduce qemu_try_blockalign()
This function returns NULL instead of aborting when an allocation fails.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Diffstat (limited to 'util/oslib-win32.c')
-rw-r--r-- | util/oslib-win32.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 507cedd84d..a3eab4acba 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -50,18 +50,23 @@ void *qemu_oom_check(void *ptr) return ptr; } -void *qemu_memalign(size_t alignment, size_t size) +void *qemu_try_memalign(size_t alignment, size_t size) { void *ptr; if (!size) { abort(); } - ptr = qemu_oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE)); + ptr = VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); trace_qemu_memalign(alignment, size, ptr); return ptr; } +void *qemu_memalign(size_t alignment, size_t size) +{ + return qemu_oom_check(qemu_try_memalign(alignment, size)); +} + void *qemu_anon_ram_alloc(size_t size) { void *ptr; |