/* -*- mode: C; c-basic-offset: 4 -*- */ #ident "$Id$" #ident "Copyright (c) 2009-2010 Tokutek Inc. All rights reserved." #include "../block_allocator.h" #include #include // Test the merger. int verbose = 0; static void print_array (u_int64_t n, const struct block_allocator_blockpair a[/*n*/]) { printf("{"); for (u_int64_t i=0; ioffset < b->offset) return -1; if (a->offset > b->offset) return +1; return 0; } static void test_merge (u_int64_t an, const struct block_allocator_blockpair a[/*an*/], u_int64_t bn, const struct block_allocator_blockpair b[/*bn*/]) { if (verbose>1) { printf("a:"); print_array(an, a); } if (verbose>1) { printf("b:"); print_array(bn, b); } struct block_allocator_blockpair *MALLOC_N(an+bn, q); struct block_allocator_blockpair *MALLOC_N(an+bn, m); if (q==0 || m==0) { fprintf(stderr, "malloc failed, continuing\n"); goto malloc_failed; } for (u_int64_t i=0; i1) { printf("q:"); print_array(an+bn, q); } if (verbose) printf("merge\n"); block_allocator_merge_blockpairs_into(an, m, bn, b); if (verbose) printf("compare\n"); if (verbose>1) { printf("m:"); print_array(an+bn, m); } for (u_int64_t i=0; i