diff --git a/codec2-1.2.0/src/codec2_alloc.cpp b/codec2-1.2.0/src/codec2_alloc.cpp index 37b7e67a..ec9e806e 100644 --- a/codec2-1.2.0/src/codec2_alloc.cpp +++ b/codec2-1.2.0/src/codec2_alloc.cpp @@ -15,12 +15,14 @@ static thread_local O1HeapInstance* Instance_ = NULL; void codec2_initialize_realtime(size_t heapSize) { #if defined(WIN32) - Heap_ = (void*)_aligned_malloc(O1HEAP_ALIGNMENT, heapSize); + Heap_ = (void*)_aligned_malloc(heapSize, O1HEAP_ALIGNMENT); #else Heap_ = (void*)aligned_alloc(O1HEAP_ALIGNMENT, heapSize); #endif // defined(WIN32) assert(Heap_ != NULL); + memset(Heap_, 0, heapSize); + Instance_ = o1heapInit(Heap_, heapSize); assert(Instance_ != NULL); } diff --git a/codec2-1.2.0/src/o1heap.c b/codec2-1.2.0/src/o1heap.c index 6af213bb..d95707e7 100644 --- a/codec2-1.2.0/src/o1heap.c +++ b/codec2-1.2.0/src/o1heap.c @@ -61,8 +61,10 @@ /// computation, which is available via compiler intrinsics. The default implementation will automatically use /// the intrinsics for some of the compilers; for others it will default to the slow software emulation, /// which can be overridden by the user via O1HEAP_CONFIG_HEADER. The library guarantees that the argument is positive. +/// +/// NOTE (MS, 2025-06-04): __builtin_clzl seems broken on LLVM MinGW, so reverting to slower emulation on Windows. #if O1HEAP_USE_INTRINSICS && !defined(O1HEAP_CLZ) -# if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM) +# if !defined(WIN32) && (defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM)) # define O1HEAP_CLZ __builtin_clzl # endif #endif