[PATCH vkd3d 2/6] libs/vkd3d-common: Move heap memory functions implementation from vkd3d_memory.h.

Matteo Bruni mbruni at codeweavers.com
Tue May 10 13:21:28 CDT 2022


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
 include/private/vkd3d_memory.h | 26 +++-----------------------
 libs/vkd3d-common/memory.c     | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/include/private/vkd3d_memory.h b/include/private/vkd3d_memory.h
index 8a2edb10..fbfee9f5 100644
--- a/include/private/vkd3d_memory.h
+++ b/include/private/vkd3d_memory.h
@@ -26,29 +26,9 @@
 
 #include "vkd3d_debug.h"
 
-static inline void *vkd3d_malloc(size_t size)
-{
-    void *ptr;
-    if (!(ptr = malloc(size)))
-        ERR("Out of memory.\n");
-    return ptr;
-}
-
-static inline void *vkd3d_realloc(void *ptr, size_t size)
-{
-    if (!(ptr = realloc(ptr, size)))
-        ERR("Out of memory, size %zu.\n", size);
-    return ptr;
-}
-
-static inline void *vkd3d_calloc(size_t count, size_t size)
-{
-    void *ptr;
-    assert(count <= ~(size_t)0 / size);
-    if (!(ptr = calloc(count, size)))
-        ERR("Out of memory.\n");
-    return ptr;
-}
+void *vkd3d_malloc(size_t size);
+void *vkd3d_realloc(void *ptr, size_t size);
+void *vkd3d_calloc(size_t count, size_t size);
 
 static inline void vkd3d_free(void *ptr)
 {
diff --git a/libs/vkd3d-common/memory.c b/libs/vkd3d-common/memory.c
index 2bf8947e..f46f180c 100644
--- a/libs/vkd3d-common/memory.c
+++ b/libs/vkd3d-common/memory.c
@@ -19,6 +19,30 @@
 
 #include "vkd3d_memory.h"
 
+void *vkd3d_malloc(size_t size)
+{
+    void *ptr;
+    if (!(ptr = malloc(size)))
+        ERR("Out of memory.\n");
+    return ptr;
+}
+
+void *vkd3d_realloc(void *ptr, size_t size)
+{
+    if (!(ptr = realloc(ptr, size)))
+        ERR("Out of memory, size %zu.\n", size);
+    return ptr;
+}
+
+void *vkd3d_calloc(size_t count, size_t size)
+{
+    void *ptr;
+    assert(count <= ~(size_t)0 / size);
+    if (!(ptr = calloc(count, size)))
+        ERR("Out of memory.\n");
+    return ptr;
+}
+
 bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
 {
     size_t new_capacity, max_capacity;
-- 
2.35.1




More information about the wine-devel mailing list