From 42ff0425a78141cad96cb51b144adf19a1bb9019 Mon Sep 17 00:00:00 2001 From: Michael Phipps Date: Sun, 24 Nov 2002 05:12:50 +0000 Subject: [PATCH] Fixed more bugs; simpleTest now seems to work correctly. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2075 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/vm2/area.C | 1 + src/kernel/vm2/hashTable.h | 14 +++++++++++--- src/kernel/vm2/hashTest.C | 6 +++++- src/kernel/vm2/simpleTest.C | 1 + 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/kernel/vm2/area.C b/src/kernel/vm2/area.C index df7fbd570e..fcac5c0a38 100644 --- a/src/kernel/vm2/area.C +++ b/src/kernel/vm2/area.C @@ -131,6 +131,7 @@ void area::freeArea(void) { //page->next=NULL; vmBlock->vpagePool->put(page); } + vpages.~hashTable(); //error ("area::freeArea: unlocking \n"); //error ("area::freeArea: ending \n"); } diff --git a/src/kernel/vm2/hashTable.h b/src/kernel/vm2/hashTable.h index cdaa9c8234..40fbf987b3 100644 --- a/src/kernel/vm2/hashTable.h +++ b/src/kernel/vm2/hashTable.h @@ -28,6 +28,8 @@ class hashTable : public list // Get the block for the page of pointers page *newPage=vmBlock->pageMan->getPage(); error ("hashTable::hashTable - Got Page %x\n",newPage); + pageList.add(newPage); + if (!newPage) { error ("Out of pages to allocate a pool! newPage = %x\n",newPage); throw ("Out of pages to allocate a pool!"); @@ -37,8 +39,7 @@ class hashTable : public list int listsPerPage=PAGE_SIZE/sizeof(list); int pages=(size+(listsPerPage-1))/listsPerPage; - for (int pageCount=0;pageCountpageMan->getPage(); error ("hashTable::hashTable - Got Page %x\n",newPage); @@ -46,9 +47,15 @@ class hashTable : public list throw ("Out of pages to allocate a pool!"); for (int i=0;igetAddress()+(i*sizeof(list)))) list; + pageList.add(newPage); } } - + ~hashTable() { + while (struct page *cur=reinterpret_cast(pageList.next())) { + error ("hashTable::~hashTable; freeing page %x\n",cur); + vmBlock->pageMan->freePage(cur); + } + } // Mutators void setHash (ulong (*hash_in)(node &)) { hash=hash_in; } void setIsEqual (bool (*isEqual_in)(node &,node &)) { isEqual=isEqual_in; } @@ -98,6 +105,7 @@ class hashTable : public list ulong (*hash)(node &a); bool (*isEqual)(node &a,node &b); list **rocks; + list pageList; int numRocks; }; diff --git a/src/kernel/vm2/hashTest.C b/src/kernel/vm2/hashTest.C index 0498457367..602fc9f123 100644 --- a/src/kernel/vm2/hashTest.C +++ b/src/kernel/vm2/hashTest.C @@ -42,7 +42,10 @@ int main(int argc,char **argv) { error ("Failure on adding with no hash, unknown exception\n"); } - hashTable foo(20); + hashTable *moo; + moo=new hashTable(20); + hashTable &foo=*moo; + foo.setHash(hash); foo.setIsEqual(isEqual); @@ -114,5 +117,6 @@ int main(int argc,char **argv) { error ("found 1000, as expected!\n"); else error ("did NOT find 1000, as expected, found %d!\n",count); + delete moo; return 0; } diff --git a/src/kernel/vm2/simpleTest.C b/src/kernel/vm2/simpleTest.C index 6ae58a48b3..eef3b4a0ef 100644 --- a/src/kernel/vm2/simpleTest.C +++ b/src/kernel/vm2/simpleTest.C @@ -31,6 +31,7 @@ int createFillAndTest(int pages,char *name) if (i%256!=readByte(addr,i)) error ("ERROR! Byte at offset %d does not match: expected: %d, found: %d\n",i,i%256,readByte(addr,i)); } + vm->freeArea(area1); error ("%s: createFillAndTest: reading done\n",name); return area1; }