summaryrefslogtreecommitdiff
path: root/zutil.c
diff options
context:
space:
mode:
authorMika Lindqvist <postmaster@raasu.org>2017-04-08 09:15:37 +0300
committerHans Kristian Rosbach <hk-github@circlestorm.org>2018-02-22 10:11:19 +0100
commit3e7e5e55b881edbafb2c79652ad87a1f6d7e602e (patch)
tree9c1edfd4b87c6264e54b421a30667b7591dd367f /zutil.c
parentb22ff7e70ed067f1ce9e4aaa548d2110b8ec9bb8 (diff)
Align in 16-byte boundary when UNALIGNED_OK is undefined.
Diffstat (limited to 'zutil.c')
-rw-r--r--zutil.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/zutil.c b/zutil.c
index ff9e8fa..70ffb84 100644
--- a/zutil.c
+++ b/zutil.c
@@ -9,6 +9,9 @@
#ifdef WITH_GZFILEOP
# include "gzguts.h"
#endif
+#ifndef UNALIGNED_OK
+# include "malloc.h"
+#endif
const char * const z_errmsg[10] = {
(const char *)"need dictionary", /* Z_NEED_DICT 2 */
@@ -119,8 +122,12 @@ const char * ZEXPORT PREFIX(zError)(int err)
void ZLIB_INTERNAL *zcalloc (void *opaque, unsigned items, unsigned size)
{
(void)opaque;
+#ifndef UNALIGNED_OK
+ return memalign(16, items * size);
+#else
return sizeof(unsigned int) > 2 ? (void *)malloc(items * size) :
(void *)calloc(items, size);
+#endif
}
void ZLIB_INTERNAL zcfree (void *opaque, void *ptr)