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
This commit is contained in:
parent
cc22bcb449
commit
42ff0425a7
@ -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");
|
||||
}
|
||||
|
@ -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;pageCount<pages;pageCount++)
|
||||
{
|
||||
for (int pageCount=0;pageCount<pages;pageCount++) {
|
||||
// Allocate a page of lists
|
||||
page *newPage=vmBlock->pageMan->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;i<listsPerPage;i++)
|
||||
rocks[i]=new ((list *)(newPage->getAddress()+(i*sizeof(list)))) list;
|
||||
pageList.add(newPage);
|
||||
}
|
||||
}
|
||||
|
||||
~hashTable() {
|
||||
while (struct page *cur=reinterpret_cast<page *>(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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user