cleaned up meaning of first constructor parameter

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4394 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2003-08-29 00:54:54 +00:00
parent 2fc06b8774
commit ad159f4343
2 changed files with 7 additions and 11 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ enum {
class BBlockCache
{
public:
BBlockCache(size_t cacheSize,
BBlockCache(uint32 blockCount,
size_t blockSize,
uint32 allocationType);
virtual ~BBlockCache();
+6 -10
View File
@@ -37,11 +37,7 @@
// are allocated than available, the variable fExcessBlocks is used to avoid
// growing the pool of free buffers
// XXX the BeBook describes the first parameter of the constructor as
// XXX "size_t count", while the original BeOS header uses "size_t cache_size"
// XXX this are very different meanings
BBlockCache::BBlockCache(size_t cacheSize,
BBlockCache::BBlockCache(uint32 blockCount,
size_t blockSize,
uint32 allocationType)
: fFreeList(0),
@@ -51,9 +47,6 @@ BBlockCache::BBlockCache(size_t cacheSize,
fAlloc(0),
fFree(0)
{
if (cacheSize < blockSize)
debugger("Error, you can't create a BBlockCache with cacheSize < blockSize\n");
switch (allocationType) {
case B_OBJECT_CACHE:
fAlloc = &operator new[];
@@ -71,10 +64,13 @@ BBlockCache::BBlockCache(size_t cacheSize,
// large enough to contain the _FreeBlock struct that is used.
if (blockSize < sizeof(_FreeBlock))
blockSize = sizeof(_FreeBlock);
// should have at least one block
if (blockCount == 0)
blockCount = 1;
// create blocks and put them into the free list
int count = cacheSize / blockSize;
for (int i = 0; i < count; i++) {
for (int32 i = 0; i < (int32)blockCount; i++) {
_FreeBlock *block = reinterpret_cast<_FreeBlock *>(fAlloc(blockSize));
if (!block)
break;