]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Align in 16-byte boundary when UNALIGNED_OK is undefined.
authorMika Lindqvist <postmaster@raasu.org>
Sat, 8 Apr 2017 06:15:37 +0000 (09:15 +0300)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 22 Feb 2018 09:11:19 +0000 (10:11 +0100)
test/minigzip.c
zutil.c

index f7e3758db516bb0cc3bb76bf9a9cfcf67550b45d..e19bda1dcbe6efb806b58c46698d5fdcdcd58bfc 100644 (file)
 #  include <sys/stat.h>
 #endif
 
+#ifndef UNALIGNED_OK
+#  include <malloc.h>
+#endif
+
 #if defined(WIN32) || defined(__CYGWIN__)
 #  include <fcntl.h>
 #  include <io.h>
@@ -70,7 +74,11 @@ void myfree (void *, void *);
 void *myalloc(void *q, unsigned n, unsigned m)
 {
     (void)q;
+#ifndef UNALIGNED_OK
+    return memalign(16, n * m);
+#else
     return calloc(n, m);
+#endif
 }
 
 void myfree(void *q, void *p)
diff --git a/zutil.c b/zutil.c
index ff9e8fa69d4ebc2067652c8a5a210a7a09e3029f..70ffb84e052434b6b31f6db3bd0c9ce2da0c0a13 100644 (file)
--- 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)