diff --git a/src/common/classes/alloc.cpp b/src/common/classes/alloc.cpp index 09d8d50467..469abf11a0 100644 --- a/src/common/classes/alloc.cpp +++ b/src/common/classes/alloc.cpp @@ -23,6 +23,7 @@ * Contributor(s): ______________________________________. */ +#include "../../include/firebird.h" #include "alloc.h" #include @@ -110,8 +111,8 @@ void MemoryPool::verify_pool() { assert(blk->prev == prev); // Prev is correct ? BlockInfo temp = {blk, blk->length}; bool foundTree = freeBlocks.locate(temp), foundPending = false; - for (PendingFreeBlock *temp = pendingFree; temp; temp = temp->next) - if (temp == (PendingFreeBlock *)((char*)blk+ALIGN(sizeof(MemoryBlock)))) { + for (PendingFreeBlock *tmp = pendingFree; tmp; tmp = tmp->next) + if (tmp == (PendingFreeBlock *)((char*)blk+ALIGN(sizeof(MemoryBlock)))) { assert(!foundPending); // Block may be in pending list only one time foundPending = true; } diff --git a/src/common/classes/class_perf.cpp b/src/common/classes/class_perf.cpp index dffc67b4cf..039e380676 100644 --- a/src/common/classes/class_perf.cpp +++ b/src/common/classes/class_perf.cpp @@ -50,7 +50,8 @@ static void testTree() { printf("Fill array with test data (%d items)...", TEST_ITEMS); Vector *v = new Vector(); int n = 0; - for (int i=0;iadd(((i+n) % TEST_ITEMS + TEST_ITEMS)/2); @@ -61,9 +62,9 @@ static void testTree() { start(); BePlusTree, DefaultComparator, 10, 10> tree10(NULL); - for (int i=0; i, DefaultComparator, 50, 50> tree50(NULL); - for (int i=0; i, DefaultComparator, 75, 75> tree75(NULL); - for (int i=0; i, DefaultComparator, 100, 100> tree100(NULL); - for (int i=0; i, DefaultComparator, 200, 200> tree200(NULL); - for (int i=0; i, DefaultComparator, 250, 250> tree250(NULL); - for (int i=0; i, DefaultComparator, 500, 500> tree500(NULL); - for (int i=0; i stlTree; start(); - for (int i=0; ialloc((n % BIG_SIZE + BIG_SIZE)/2+1)}; bigItems.add(temp); @@ -259,7 +261,7 @@ static void testAllocatorMalloc() { n++; } while (n < ALLOC_ITEMS/2 && items.getNext()); // Allocate big items - for (int i=0;iallocate((n % MAX_ITEM_SIZE + MAX_ITEM_SIZE)/2+1,0)}; items.add(temp); @@ -296,7 +299,7 @@ static void testAllocatorOldPool() { n++; } while (n < ALLOC_ITEMS/2 && items.getNext()); // Allocate big items - for (int i=0;iallocate((n % BIG_SIZE + BIG_SIZE)/2+1,0)}; bigItems.add(temp); diff --git a/src/common/classes/class_test.cpp b/src/common/classes/class_test.cpp index 331d59007f..a30f1198cf 100644 --- a/src/common/classes/class_test.cpp +++ b/src/common/classes/class_test.cpp @@ -23,6 +23,7 @@ * Contributor(s): ______________________________________. */ +#include "../../include/firebird.h" #include "tree.h" #include "alloc.h" #include @@ -32,12 +33,13 @@ using namespace Firebird; void testVector() { printf("Test Firebird::Vector: "); Vector v; - for (int i=0;i<100;i++) + int i; + for (i=0;i<100;i++) v.add(i); - for (int i=0;i<50;i++) + for (i=0;i<50;i++) v.remove(0); bool passed = true; - for (int i=50;i<100;i++) + for (i=50;i<100;i++) if (v[i-50] != i) passed = false; printf(passed?"PASSED\n":"FAILED\n"); } @@ -45,12 +47,13 @@ void testVector() { void testSortedVector() { printf("Test Firebird::SortedVector: "); SortedVector v; - for (int i=0;i<100;i++) + int i; + for (i=0;i<100;i++) v.add(99-i); - for (int i=0;i<50;i++) + for (i=0;i<50;i++) v.remove(0); bool passed = true; - for (int i=50;i<100;i++) + for (i=50;i<100;i++) if (v[i-50] != i) passed = false; printf(passed?"PASSED\n":"FAILED\n"); } @@ -66,13 +69,14 @@ struct Test { }; void testBePlusTree() { - MallocAllocator temp; - printf("Test Firebird::BePlusTree\n"); + MallocAllocator temp; + printf("Test Firebird::BePlusTree\n"); - printf("Fill array with test data (%d items)...", TEST_ITEMS); + printf("Fill array with test data (%d items)...", TEST_ITEMS); Vector v; int n = 0; - for (int i=0;i, 13, 13> tree2(&temp); int cnt1 = 0, cnt2 = 0; - for (int i=0; i < v.getCount(); i++) { + for (i=0; i < v.getCount(); i++) { if (tree1.locate(locEqual, v[i])) tree1.current().count++; else { @@ -112,7 +116,7 @@ void testBePlusTree() { bool passed = true; printf("Check that tree(2) contains test data: "); - for (int i=0; i< v.getCount(); i++) { + for (i=0; i< v.getCount(); i++) { if(!tree1.locate(locEqual,v[i])) passed = false; } @@ -120,7 +124,7 @@ void testBePlusTree() { passed = true; printf("Check that tree(13) contains test data: "); - for (int i=0; i< v.getCount(); i++) { + for (i=0; i< v.getCount(); i++) { if(!tree2.locate(locEqual,v[i])) passed = false; } @@ -173,7 +177,7 @@ void testBePlusTree() { printf(" DONE\n"); printf("Check that tree(2) contains test data: "); - for (int i=0; i< v.getCount(); i++) { + for (i=0; i< v.getCount(); i++) { if(!tree1.locate(locEqual,v[i])) passed = false; } @@ -181,7 +185,7 @@ void testBePlusTree() { passed = true; printf("Check that tree(13) contains test data: "); - for (int i=0; i < v.getCount(); i++) { + for (i=0; i < v.getCount(); i++) { if(!tree2.locate(locEqual,v[i])) passed = false; } @@ -215,7 +219,7 @@ void testBePlusTree() { passed = true; printf("Remove the rest of data from the trees: "); - for (int i=0;i < v.getCount(); i++) { + for (i=0;i < v.getCount(); i++) { if (!tree1.locate(locEqual, v[i])) assert(false); if (tree1.current().count > 1) @@ -241,7 +245,6 @@ void testBePlusTree() { if (tree2.getLast()) passed = false; printf(passed?"PASSED\n":"FAILED\n"); - } #define ALLOC_ITEMS 1000000 @@ -266,8 +269,9 @@ void testAllocator() { bigItems(&allocator); printf("Allocate %d items: ", ALLOC_ITEMS); int n = 0; + int i; pool->verify_pool(); - for (int i=0;ialloc((n % MAX_ITEM_SIZE + MAX_ITEM_SIZE)/2+1)}; items.add(temp); @@ -287,7 +291,7 @@ void testAllocator() { printf("Allocate %d big items: ", BIG_ITEMS); n = 0; pool->verify_pool(); - for (int i=0;ialloc((n % BIG_SIZE + BIG_SIZE)/2+1)}; bigItems.add(temp); @@ -313,7 +317,7 @@ void testAllocator() { MemoryPool::deletePool(pool); } -int main() { +void main() { testVector(); testSortedVector(); testBePlusTree();