mirror of
https://github.com/GerbilSoft/zlib-ng.git
synced 2025-06-19 03:55:39 -04:00
Memory alloc size must be a multiple of alignment for aligned_alloc.
This commit is contained in:
parent
42db8b86a8
commit
2a03576b34
@ -17,6 +17,8 @@
|
|||||||
/* Function to allocate 16 or 64-byte aligned memory */
|
/* Function to allocate 16 or 64-byte aligned memory */
|
||||||
static inline void *zng_alloc(size_t size) {
|
static inline void *zng_alloc(size_t size) {
|
||||||
#ifdef HAVE_ALIGNED_ALLOC
|
#ifdef HAVE_ALIGNED_ALLOC
|
||||||
|
/* Size must be a multiple of alignment */
|
||||||
|
size = (size + (64 - 1)) & ~(64 - 1);
|
||||||
return (void *)aligned_alloc(64, size); /* Defined in C11 */
|
return (void *)aligned_alloc(64, size); /* Defined in C11 */
|
||||||
#elif defined(HAVE_POSIX_MEMALIGN)
|
#elif defined(HAVE_POSIX_MEMALIGN)
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user