示例#1
0
/* Test the Toolkit's array class, used for internal lists of primitive types */
void test_array()
{
    puts("\nTesting Toolkit array template:\n");

    utxArray<int> arr;
    arr.push_back(0);
    printf("  added item, size is %d, capacity is %d, alloc count is %d\n", arr.size(), arr.capacity(), utGetAllocCount());
    verify_alloc(1);

    arr.push_back(1);
    printf("  added item, size is %d, capacity is %d, realloc count is %d\n", arr.size(), arr.capacity(), utGetReallocCount());
    verify_realloc(1);

    arr.push_back(2);
    printf("  added item, size is %d, capacity is %d, realloc count is %d\n", arr.size(), arr.capacity(), utGetReallocCount());
    verify_realloc(1);

    arr.push_back(3);
    printf("  added item, size is %d, capacity is %d, realloc count is %d\n", arr.size(), arr.capacity(), utGetReallocCount());
    verify_realloc(0);

    arr.clear();
    printf("  array cleared, free count is %d\n", utGetFreeCount());
    verify_free(1);
}
示例#2
0
/* Test replacement C-style allocators */
void test_c_allocators()
{
    puts("\nTesting C allocators:\n");

    void* ptr = utALLOC(32);
    printf("  ptr is %p, alloc count is %d\n", ptr, utGetAllocCount());
    ptr = utREALLOC(ptr, 64);
    printf("  realloced ptr is %p, realloc count is %d\n", ptr, utGetReallocCount());
    utFREE(ptr);
    printf("  ptr freed, free count is %d\n", utGetFreeCount());

    verify_alloc(1);
    verify_realloc(1);
    verify_free(1);
}
示例#3
0
/* Test custom memory allocation callbacks */
void test_custom_allocators()
{
    puts("\nTesting custom allocators:\n");

    utSetAllocHandlers(myAlloc, myRealloc, myFree);
    void* ptr = utALLOC(32);
    if (numCustom != 1)
        die("alloc callback failed");
    printf("  ptr is %p, alloc count is %d\n", ptr, utGetAllocCount());

    ptr = utREALLOC(ptr, 64);
    if (numCustom != 2)
        die("realloc callback failed");
    printf("  realloced ptr is %p, realloc count is %d\n", ptr, utGetReallocCount());

    utFREE(ptr);
    if (numCustom != 3)
        die("free callback failed");
    printf("  ptr freed, free count is %d\n", utGetFreeCount());

    verify_alloc(1);
    verify_realloc(1);
    verify_free(1);
}
示例#4
0
/**
 * Stops the background task for tigertree verification.
 */
void G_COLD
verify_tth_shutdown(void)
{
	verify_free(&verify_tth.verify);
}
示例#5
0
void
verify_sha1_close(void)
{
	verify_free(&verify_sha1.verify);
}
示例#6
0
/**
 * Stops the background task for tigertree verification.
 */
void
verify_tth_close(void)
{
	verify_free(&verify_tth.verify);
	HFREE_NULL(verify_tth.context);
}