util: Put qemu_vfree() in memalign.c

qemu_vfree() is the companion free function to qemu_memalign(); put
it in memalign.c so the allocation and free functions are together.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20220226180723.1706285-9-peter.maydell@linaro.org
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
Peter Maydell 2022-02-26 18:07:22 +00:00
parent 88454f844e
commit 1a11265d7e
3 changed files with 11 additions and 12 deletions

View File

@ -78,3 +78,14 @@ void *qemu_memalign(size_t alignment, size_t size)
size, alignment, strerror(errno)); size, alignment, strerror(errno));
abort(); abort();
} }
void qemu_vfree(void *ptr)
{
trace_qemu_vfree(ptr);
#if !defined(CONFIG_POSIX_MEMALIGN) && defined(CONFIG_ALIGNED_MALLOC)
/* Only Windows _aligned_malloc needs a special free function */
_aligned_free(ptr);
#else
free(ptr);
#endif
}

View File

@ -220,12 +220,6 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared,
return ptr; return ptr;
} }
void qemu_vfree(void *ptr)
{
trace_qemu_vfree(ptr);
free(ptr);
}
void qemu_anon_ram_free(void *ptr, size_t size) void qemu_anon_ram_free(void *ptr, size_t size)
{ {
trace_qemu_anon_ram_free(ptr, size); trace_qemu_anon_ram_free(ptr, size);

View File

@ -75,12 +75,6 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared,
return ptr; return ptr;
} }
void qemu_vfree(void *ptr)
{
trace_qemu_vfree(ptr);
_aligned_free(ptr);
}
void qemu_anon_ram_free(void *ptr, size_t size) void qemu_anon_ram_free(void *ptr, size_t size)
{ {
trace_qemu_anon_ram_free(ptr, size); trace_qemu_anon_ram_free(ptr, size);