aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2022-02-26 18:07:22 +0000
committerPeter Maydell <peter.maydell@linaro.org>2022-03-07 13:16:24 +0000
commit1a11265d7e854203652606b671a0e02ba100a249 (patch)
tree7f96eae377c21e7e8b04cd329a7d907e9093308e
parent88454f844efe26ea8ac7f394a72b1e6620dccf7e (diff)
downloadqemu-1a11265d7e854203652606b671a0e02ba100a249.zip
qemu-1a11265d7e854203652606b671a0e02ba100a249.tar.gz
qemu-1a11265d7e854203652606b671a0e02ba100a249.tar.bz2
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>
-rw-r--r--util/memalign.c11
-rw-r--r--util/oslib-posix.c6
-rw-r--r--util/oslib-win32.c6
3 files changed, 11 insertions, 12 deletions
diff --git a/util/memalign.c b/util/memalign.c
index 083aaae..440b8fd 100644
--- a/util/memalign.c
+++ b/util/memalign.c
@@ -78,3 +78,14 @@ void *qemu_memalign(size_t alignment, size_t size)
size, alignment, strerror(errno));
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
+}
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 91798f7..2ebfb75 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -220,12 +220,6 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared,
return ptr;
}
-void qemu_vfree(void *ptr)
-{
- trace_qemu_vfree(ptr);
- free(ptr);
-}
-
void qemu_anon_ram_free(void *ptr, size_t size)
{
trace_qemu_anon_ram_free(ptr, size);
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index d976853..4b1ce0b 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -75,12 +75,6 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *align, bool shared,
return ptr;
}
-void qemu_vfree(void *ptr)
-{
- trace_qemu_vfree(ptr);
- _aligned_free(ptr);
-}
-
void qemu_anon_ram_free(void *ptr, size_t size)
{
trace_qemu_anon_ram_free(ptr, size);