summaryrefslogtreecommitdiffstats
path: root/src/util/os_memory_stdc.h
diff options
context:
space:
mode:
authorDylan Baker <[email protected]>2018-09-12 16:26:38 -0700
committerDylan Baker <[email protected]>2020-04-21 11:09:03 -0700
commitbb560f2d653dd5d080c7f03859936ce50bea5b72 (patch)
treeff08455bd067485b901520f8e1ec84b7c2b41e81 /src/util/os_memory_stdc.h
parentb85775900d084e3d27f269c3bd336b9aa356b98d (diff)
util: Add an aligned realloc function
Mesa has one of these in imports.h, so u_memory needs one as well. This is the version from mesa ported. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>
Diffstat (limited to 'src/util/os_memory_stdc.h')
-rw-r--r--src/util/os_memory_stdc.h18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/util/os_memory_stdc.h b/src/util/os_memory_stdc.h
index a4a670d589a..bda5715998f 100644
--- a/src/util/os_memory_stdc.h
+++ b/src/util/os_memory_stdc.h
@@ -45,27 +45,13 @@
#define os_realloc( _old_ptr, _old_size, _new_size) \
realloc(_old_ptr, _new_size + 0*(_old_size))
-
-#if defined(HAVE_POSIX_MEMALIGN)
-
-static inline void *
-os_malloc_aligned(size_t size, size_t alignment)
-{
- void *ptr;
- alignment = (alignment + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
- if(posix_memalign(&ptr, alignment, size) != 0)
- return NULL;
- return ptr;
-}
-
-#define os_free_aligned(_ptr) free(_ptr)
-
-#elif DETECT_OS_WINDOWS
+#if DETECT_OS_WINDOWS
#include <malloc.h>
#define os_malloc_aligned(_size, _align) _aligned_malloc(_size, _align)
#define os_free_aligned(_ptr) _aligned_free(_ptr)
+#define os_realloc_aligned(_ptr, _oldsize, _newsize, _alignment) _aligned_realloc(_ptr, _newsize, _alignment)
#else