Use zng_alloc_aligned in unit tests to prevent having to use C++17.

alloc_aligned when using in C++ requires C++17 standard. zutil_p.h
include removed from test_crc32 since it was causing the same issue and was
not really needed.

GitOrigin-RevId: 9d33c8163d69452079918676453b65f780b11de8
Change-Id: Ifb10a7a22db17486480cb06b24cf1318a252322d
diff --git a/test/test_compare256.cc b/test/test_compare256.cc
index 8900902..b85dc1b 100644
--- a/test/test_compare256.cc
+++ b/test/test_compare256.cc
@@ -9,7 +9,7 @@
 
 extern "C" {
 #  include "zbuild.h"
-#  include "zutil_p.h"
+#  include "zutil.h"
 #  include "test_cpu_features.h"
 }
 
@@ -26,11 +26,11 @@
     uint8_t *str1;
     uint8_t *str2;
 
-    str1 = (uint8_t *)zng_alloc(MAX_COMPARE_SIZE);
+    str1 = (uint8_t *)PREFIX3(alloc_aligned)(NULL, NULL, 1, MAX_COMPARE_SIZE, 64);
     ASSERT_TRUE(str1 != NULL);
     memset(str1, 'a', MAX_COMPARE_SIZE);
 
-    str2 = (uint8_t *)zng_alloc(MAX_COMPARE_SIZE);
+    str2 = (uint8_t *)PREFIX3(alloc_aligned)(NULL, NULL, 1, MAX_COMPARE_SIZE, 64);
     ASSERT_TRUE(str2 != NULL);
     memset(str2, 'a', MAX_COMPARE_SIZE);
 
@@ -45,8 +45,8 @@
             str2[i] = 'a';
     }
 
-    zng_free(str1);
-    zng_free(str2);
+    PREFIX3(free_aligned)(NULL, NULL, str1);
+    PREFIX3(free_aligned)(NULL, NULL, str2);
 }
 
 #define TEST_COMPARE256(name, func, support_flag) \
diff --git a/test/test_compare256_rle.cc b/test/test_compare256_rle.cc
index da60d6f..4123ef2 100644
--- a/test/test_compare256_rle.cc
+++ b/test/test_compare256_rle.cc
@@ -9,7 +9,7 @@
 
 extern "C" {
 #  include "zbuild.h"
-#  include "zutil_p.h"
+#  include "zutil.h"
 #  include "compare256_rle.h"
 }
 
@@ -23,7 +23,7 @@
     uint8_t str1[] = {'a', 'a', 0};
     uint8_t *str2;
 
-    str2 = (uint8_t *)zng_alloc(MAX_COMPARE_SIZE);
+    str2 = (uint8_t *)PREFIX3(alloc_aligned)(NULL, NULL, 1, MAX_COMPARE_SIZE, 64);
     ASSERT_TRUE(str2 != NULL);
     memset(str2, 'a', MAX_COMPARE_SIZE);
 
@@ -38,7 +38,7 @@
             str2[i] = 'a';
     }
 
-    zng_free(str2);
+    PREFIX3(free_aligned)(NULL, NULL, str2);
 }
 
 #define TEST_COMPARE256_RLE(name, func, support_flag) \
diff --git a/test/test_crc32.cc b/test/test_crc32.cc
index 0cdc317..2371127 100644
--- a/test/test_crc32.cc
+++ b/test/test_crc32.cc
@@ -11,7 +11,6 @@
 
 extern "C" {
 #  include "zbuild.h"
-#  include "zutil_p.h"
 #  include "test_cpu_features.h"
 }
 
diff --git a/zutil.c b/zutil.c
index 270a28c..ce620e3 100644
--- a/zutil.c
+++ b/zutil.c
@@ -118,7 +118,7 @@
     void *ptr;
 
     /* If no custom calloc function used then call zlib-ng's aligned calloc */
-    if (zalloc == PREFIX(zcalloc))
+    if (zalloc == NULL || zalloc == PREFIX(zcalloc))
         return PREFIX(zcalloc)(opaque, items, size);
 
     /* Allocate enough memory for proper alignment and to store the original memory pointer */
@@ -143,7 +143,7 @@
 
 void Z_INTERNAL PREFIX3(free_aligned)(zng_cfree_func zfree, void *opaque, void *ptr) {
     /* If no custom cfree function used then call zlib-ng's aligned cfree */
-    if (zfree == PREFIX(zcfree)) {
+    if (zfree == NULL || zfree == PREFIX(zcfree)) {
         PREFIX(zcfree)(opaque, ptr);
         return;
     }