[fix] use aligned_alloc only if glibc >= 2.16 (#2598)

This commit is contained in:
Gautier Hattenberger
2020-10-13 11:14:45 +02:00
committed by GitHub
parent 9ace12432c
commit f8f4142f6b
@@ -60,8 +60,12 @@ void image_create(struct image_t *img, uint16_t width, uint16_t height, enum ima
img->buf_size = sizeof(uint8_t) * width * height;
}
#if __GLIBC__ > 2 || (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 16)
// aligned memory slightly speeds up any later copies
img->buf = aligned_alloc(CACHE_LINE_LENGTH, img->buf_size + (CACHE_LINE_LENGTH - img->buf_size % CACHE_LINE_LENGTH) % CACHE_LINE_LENGTH);
#else
img->buf = malloc(img->buf_size);
#endif
}
/**