Skip to content

Commit

Permalink
Switch to malloc for valgrind testing
Browse files Browse the repository at this point in the history
  • Loading branch information
asweeney86 committed Dec 21, 2017
1 parent bd73c13 commit 8784fd4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/check_an_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AN_ARRAY(node, test);
AN_ARRAY_PRIMITIVE(int, test2);

static struct allocator_stats {
size_t n_malloc;
size_t n_calloc;
size_t n_realloc;
size_t n_free;
Expand All @@ -32,7 +33,11 @@ check_calloc(const void *ctx, size_t nmemb, size_t size, void *return_addr)
static void *
check_malloc(const void *ctx, size_t size, void *return_addr)
{
return check_calloc(ctx, 1, size, return_addr);
(void)ctx;
(void)return_addr;

allocator_stats.n_malloc++;
return malloc(size);
}

static void *
Expand Down Expand Up @@ -247,7 +252,7 @@ START_TEST(allocator)
AN_ARRAY_RESIZE(test2, &array, 128);
AN_ARRAY_DEINIT(test2, &array);

ck_assert(allocator_stats.n_calloc > 0);
ck_assert(allocator_stats.n_calloc + allocator_stats.n_malloc > 0);
ck_assert(allocator_stats.n_realloc > 0);
ck_assert(allocator_stats.n_free > 0);

Expand Down

0 comments on commit 8784fd4

Please sign in to comment.