]> git.saurik.com Git - redis.git/blobdiff - deps/jemalloc/test/bitmap.c
redis-check-dump now understands dumps produced by Redis 2.6
[redis.git] / deps / jemalloc / test / bitmap.c
index adfaacfe52b7da2a41fca3c6c82066de743ef4e3..b2cb63004bca0de6f4e21408e0e2925006114414 100644 (file)
@@ -1,18 +1,6 @@
 #define        JEMALLOC_MANGLE
 #include "jemalloc_test.h"
 
 #define        JEMALLOC_MANGLE
 #include "jemalloc_test.h"
 
-/*
- * Avoid using the assert() from jemalloc_internal.h, since it requires
- * internal libjemalloc functionality.
- * */
-#include <assert.h>
-
-/*
- * Directly include the bitmap code, since it isn't exposed outside
- * libjemalloc.
- */
-#include "../src/bitmap.c"
-
 #if (LG_BITMAP_MAXBITS > 12)
 #  define MAXBITS      4500
 #else
 #if (LG_BITMAP_MAXBITS > 12)
 #  define MAXBITS      4500
 #else
@@ -42,11 +30,13 @@ test_bitmap_init(void)
                bitmap_info_init(&binfo, i);
                {
                        size_t j;
                bitmap_info_init(&binfo, i);
                {
                        size_t j;
-                       bitmap_t bitmap[bitmap_info_ngroups(&binfo)];
+                       bitmap_t *bitmap = malloc(sizeof(bitmap_t) *
+                               bitmap_info_ngroups(&binfo));
                        bitmap_init(bitmap, &binfo);
 
                        for (j = 0; j < i; j++)
                                assert(bitmap_get(bitmap, &binfo, j) == false);
                        bitmap_init(bitmap, &binfo);
 
                        for (j = 0; j < i; j++)
                                assert(bitmap_get(bitmap, &binfo, j) == false);
+                       free(bitmap);
 
                }
        }
 
                }
        }
@@ -62,12 +52,14 @@ test_bitmap_set(void)
                bitmap_info_init(&binfo, i);
                {
                        size_t j;
                bitmap_info_init(&binfo, i);
                {
                        size_t j;
-                       bitmap_t bitmap[bitmap_info_ngroups(&binfo)];
+                       bitmap_t *bitmap = malloc(sizeof(bitmap_t) *
+                               bitmap_info_ngroups(&binfo));
                        bitmap_init(bitmap, &binfo);
 
                        for (j = 0; j < i; j++)
                                bitmap_set(bitmap, &binfo, j);
                        assert(bitmap_full(bitmap, &binfo));
                        bitmap_init(bitmap, &binfo);
 
                        for (j = 0; j < i; j++)
                                bitmap_set(bitmap, &binfo, j);
                        assert(bitmap_full(bitmap, &binfo));
+                       free(bitmap);
                }
        }
 }
                }
        }
 }
@@ -82,7 +74,8 @@ test_bitmap_unset(void)
                bitmap_info_init(&binfo, i);
                {
                        size_t j;
                bitmap_info_init(&binfo, i);
                {
                        size_t j;
-                       bitmap_t bitmap[bitmap_info_ngroups(&binfo)];
+                       bitmap_t *bitmap = malloc(sizeof(bitmap_t) *
+                               bitmap_info_ngroups(&binfo));
                        bitmap_init(bitmap, &binfo);
 
                        for (j = 0; j < i; j++)
                        bitmap_init(bitmap, &binfo);
 
                        for (j = 0; j < i; j++)
@@ -93,6 +86,7 @@ test_bitmap_unset(void)
                        for (j = 0; j < i; j++)
                                bitmap_set(bitmap, &binfo, j);
                        assert(bitmap_full(bitmap, &binfo));
                        for (j = 0; j < i; j++)
                                bitmap_set(bitmap, &binfo, j);
                        assert(bitmap_full(bitmap, &binfo));
+                       free(bitmap);
                }
        }
 }
                }
        }
 }
@@ -107,7 +101,8 @@ test_bitmap_sfu(void)
                bitmap_info_init(&binfo, i);
                {
                        ssize_t j;
                bitmap_info_init(&binfo, i);
                {
                        ssize_t j;
-                       bitmap_t bitmap[bitmap_info_ngroups(&binfo)];
+                       bitmap_t *bitmap = malloc(sizeof(bitmap_t) *
+                               bitmap_info_ngroups(&binfo));
                        bitmap_init(bitmap, &binfo);
 
                        /* Iteratively set bits starting at the beginning. */
                        bitmap_init(bitmap, &binfo);
 
                        /* Iteratively set bits starting at the beginning. */
@@ -137,6 +132,7 @@ test_bitmap_sfu(void)
                        }
                        assert(bitmap_sfu(bitmap, &binfo) == i - 1);
                        assert(bitmap_full(bitmap, &binfo));
                        }
                        assert(bitmap_sfu(bitmap, &binfo) == i - 1);
                        assert(bitmap_full(bitmap, &binfo));
+                       free(bitmap);
                }
        }
 }
                }
        }
 }
@@ -144,7 +140,7 @@ test_bitmap_sfu(void)
 int
 main(void)
 {
 int
 main(void)
 {
-       fprintf(stderr, "Test begin\n");
+       malloc_printf("Test begin\n");
 
        test_bitmap_size();
        test_bitmap_init();
 
        test_bitmap_size();
        test_bitmap_init();
@@ -152,6 +148,6 @@ main(void)
        test_bitmap_unset();
        test_bitmap_sfu();
 
        test_bitmap_unset();
        test_bitmap_sfu();
 
-       fprintf(stderr, "Test end\n");
+       malloc_printf("Test end\n");
        return (0);
 }
        return (0);
 }