diff options
author | Ken Brown <kbrown@cornell.edu> | 2018-11-12 13:48:46 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gmail.com> | 2018-11-16 00:42:52 -0500 |
commit | 529c471f7b574f5e6bf7d75cde1dd89f7b26a2cf (patch) | |
tree | d6b24fafed17b18aee3551a685b84dc62379cc91 /src/gd_topal.c | |
parent | 434b639d53a8fa711bc7697944e3b05b05cdecd0 (diff) | |
download | libgd-529c471f7b574f5e6bf7d75cde1dd89f7b26a2cf.tar.gz |
Fix #479: Provide a suitable malloc function to liq
liq requires 16 byte alignment, which gdMalloc() doesn't guarantee.
Define and use a new malloc16() function when building with liq.
Diffstat (limited to 'src/gd_topal.c')
-rw-r--r-- | src/gd_topal.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gd_topal.c b/src/gd_topal.c index 5178277..5ac226a 100644 --- a/src/gd_topal.c +++ b/src/gd_topal.c @@ -1523,6 +1523,15 @@ static void free_truecolor_image_data(gdImagePtr oim) oim->tpixels = 0; } +#ifdef HAVE_LIBIMAGEQUANT +/* liq requires 16 byte aligned heap memory */ +static void *malloc16(size_t size) +{ + void *p; + return posix_memalign(&p, 16, size) == 0 ? p : NULL; +} +#endif + /* * Module initialization routine for 2-pass color quantization. */ @@ -1601,7 +1610,7 @@ static int gdImageTrueColorToPaletteBody (gdImagePtr oim, int dither, int colors #ifdef HAVE_LIBIMAGEQUANT if (oim->paletteQuantizationMethod == GD_QUANT_DEFAULT || oim->paletteQuantizationMethod == GD_QUANT_LIQ) { - liq_attr *attr = liq_attr_create_with_allocator(gdMalloc, gdFree); + liq_attr *attr = liq_attr_create_with_allocator(malloc16, free); liq_image *image; liq_result *remap; int remapped_ok = 0; |