From 03de31209417510d3e6efef791fb7bf573d38fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20Ha=CC=88user?= <8659494+mhaeuser@users.noreply.github.com> Date: Tue, 13 Jun 2023 13:34:59 +0200 Subject: [PATCH] BaseTools/CommonLib: Replace aligned_alloc with posix_memalign --- BaseTools/Source/C/Common/CommonLib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c index d5f845b568..98176555af 100644 --- a/BaseTools/Source/C/Common/CommonLib.c +++ b/BaseTools/Source/C/Common/CommonLib.c @@ -502,7 +502,15 @@ InternalAlignedAlloc ( ) { #ifndef _WIN32 - return aligned_alloc (Alignment, Size); + int Result; + void *Buffer; + + Result = posix_memalign (&Buffer, Alignment, Size); + if (Result != 0) { + return NULL; + } + + return Buffer; #else return _aligned_malloc (Size, Alignment); #endif