tests/test_allocator.c

changeset 1319
aa1f580f8f59
parent 1318
12fa1d37fe48
--- a/tests/test_allocator.c	Thu May 15 16:02:54 2025 +0200
+++ b/tests/test_allocator.c	Thu May 15 16:12:09 2025 +0200
@@ -37,79 +37,79 @@
 #include <errno.h>
 
 CX_TEST(test_allocator_default_malloc) {
-    void *test = cxMalloc(cxDefaultAllocator, 16);
+    void *test = cxMallocDefault(16);
     CX_TEST_DO {
         CX_TEST_ASSERT(test != NULL);
         // we cannot assert sth. but valgrind will detect an error
         memcpy(test, "0123456789ABCDEF", 16);
     }
-    cxFree(cxDefaultAllocator, test);
+    cxFreeDefault(test);
 }
 
 CX_TEST(test_allocator_default_calloc) {
-    char *test = cxCalloc(cxDefaultAllocator, 8, 2);
+    char *test = cxCallocDefault(8, 2);
     CX_TEST_DO {
         CX_TEST_ASSERT(test != NULL);
         for (int i = 0; i < 16; i++) {
             CX_TEST_ASSERT(test[i] == 0);
         }
     }
-    cxFree(cxDefaultAllocator, test);
+    cxFreeDefault(test);
 }
 
 CX_TEST(test_allocator_default_realloc) {
-    char *test = cxCalloc(cxDefaultAllocator, 8, 1);
+    char *test = cxCallocDefault(8, 1);
     memcpy(test, "Test", 5);
     CX_TEST_DO {
-        test = cxRealloc(cxDefaultAllocator, test, 16);
+        test = cxReallocDefault(test, 16);
         CX_TEST_ASSERT(test != NULL);
         CX_TEST_ASSERT(0 == strcmp(test, "Test"));
     }
-    cxFree(cxDefaultAllocator, test);
+    cxFreeDefault(test);
 }
 
 CX_TEST(test_allocator_default_reallocarray) {
-    char *test = cxCalloc(cxDefaultAllocator, 8, 1);
+    char *test = cxCallocDefault(8, 1);
     memcpy(test, "Test", 5);
     CX_TEST_DO {
-        test = cxReallocArray(cxDefaultAllocator, test, 16, 2);
+        test = cxReallocArrayDefault(test, 16, 2);
         CX_TEST_ASSERT(test != NULL);
         CX_TEST_ASSERT(0 == strcmp(test, "Test"));
     }
-    cxFree(cxDefaultAllocator, test);
+    cxFreeDefault(test);
 }
 
 CX_TEST(test_allocator_default_reallocarray_overflow) {
-    char *test = cxCalloc(cxDefaultAllocator, 8, 1);
+    char *test = cxCallocDefault(8, 1);
     memcpy(test, "Test", 5);
     CX_TEST_DO {
-        void *fail = cxReallocArray(cxDefaultAllocator, test, SIZE_MAX/2, 4);
+        void *fail = cxReallocArrayDefault(test, SIZE_MAX/2, 4);
         CX_TEST_ASSERT(errno == EOVERFLOW);
         CX_TEST_ASSERT(fail == NULL);
         CX_TEST_ASSERT(0 == strcmp(test, "Test"));
     }
-    cxFree(cxDefaultAllocator, test);
+    cxFreeDefault(test);
 }
 
 CX_TEST(test_allocator_default_free) {
-    void *test = cxMalloc(cxDefaultAllocator, 16);
+    void *test = cxMallocDefault(16);
     CX_TEST_DO {
         // we cannot assert sth. but valgrind will detect an error
-        cxFree(cxDefaultAllocator, test);
+        cxFreeDefault(test);
         CX_TEST_ASSERT(true);
     }
 }
 
 CX_TEST(test_allocator_reallocate) {
-    char *test = cxCalloc(cxDefaultAllocator, 8, 1);
+    char *test = cxCallocDefault(8, 1);
     memcpy(test, "Test", 5);
     CX_TEST_DO {
-        int ret = cxReallocate(cxDefaultAllocator, &test, 16);
+        int ret = cxReallocateDefault(&test, 16);
         CX_TEST_ASSERT(ret == 0);
         CX_TEST_ASSERT(test != NULL);
         CX_TEST_ASSERT(0 == strcmp(test, "Test"));
     }
-    cxFree(cxDefaultAllocator, test);
+    cxFreeDefault(test);
 }
 
 CX_TEST(test_allocator_reallocate_low_level) {
@@ -125,28 +125,28 @@
 }
 
 CX_TEST(test_allocator_reallocatearray) {
-    char *test = cxCalloc(cxDefaultAllocator, 8, 1);
+    char *test = cxCallocDefault(8, 1);
     memcpy(test, "Test", 5);
     CX_TEST_DO {
-        int ret = cxReallocateArray(cxDefaultAllocator, &test, 16, 2);
+        int ret = cxReallocateArrayDefault(&test, 16, 2);
         CX_TEST_ASSERT(ret == 0);
         CX_TEST_ASSERT(test != NULL);
         CX_TEST_ASSERT(0 == strcmp(test, "Test"));
     }
-    cxFree(cxDefaultAllocator, test);
+    cxFreeDefault(test);
 }
 
 CX_TEST(test_allocator_reallocatearray_overflow) {
-    char *test = cxCalloc(cxDefaultAllocator, 8, 1);
+    char *test = cxCallocDefault(8, 1);
     memcpy(test, "Test", 5);
     CX_TEST_DO {
-        int ret = cxReallocateArray(cxDefaultAllocator, &test, SIZE_MAX/2, 4);
+        int ret = cxReallocateArrayDefault(&test, SIZE_MAX/2, 4);
         CX_TEST_ASSERT(ret != 0);
         CX_TEST_ASSERT(errno == EOVERFLOW);
         CX_TEST_ASSERT(test != NULL);
         CX_TEST_ASSERT(0 == strcmp(test, "Test"));
     }
-    cxFree(cxDefaultAllocator, test);
+    cxFreeDefault(test);
 }
 
 CX_TEST(test_allocator_reallocatearray_low_level) {

mercurial