* Replaced the useless InitCheck() method in {Open,Multi}HashTable (it

always returned B_OK) by a Init() method, which sets the initial size
  and returns an error, if that fails.
* Adjusted code using the classes accordingly. Replaced a few
  InitCheck() methods in the network code by Init().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26127 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-06-24 22:23:57 +00:00
parent 55c692b304
commit 276aa463ef
12 changed files with 47 additions and 43 deletions
+6 -9
View File
@@ -59,26 +59,21 @@ public:
// regrowth factor: 200 / 256 = 78.125%
// 50 / 256 = 19.53125%
OpenHashTable(size_t initialSize = kMinimumSize)
OpenHashTable()
:
fTableSize(0),
fItemCount(0),
fTable(NULL)
{
if (initialSize > 0)
_Resize(initialSize);
}
OpenHashTable(const Definition& definition,
size_t initialSize = kMinimumSize)
OpenHashTable(const Definition& definition)
:
fDefinition(definition),
fTableSize(0),
fItemCount(0),
fTable(NULL)
{
if (initialSize > 0)
_Resize(initialSize);
}
~OpenHashTable()
@@ -86,9 +81,11 @@ public:
delete [] fTable;
}
status_t InitCheck() const
status_t Init(size_t initialSize = kMinimumSize)
{
return (fTableSize == 0 || fTable) ? B_OK : B_NO_MEMORY;
if (initialSize > 0 && !_Resize(initialSize))
return B_NO_MEMORY;
return B_OK;
}
ValueType *Lookup(const KeyType &key) const