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:
@@ -41,7 +41,7 @@ enum {
|
|||||||
class BBlockCache
|
class BBlockCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BBlockCache(size_t cacheSize,
|
BBlockCache(uint32 blockCount,
|
||||||
size_t blockSize,
|
size_t blockSize,
|
||||||
uint32 allocationType);
|
uint32 allocationType);
|
||||||
virtual ~BBlockCache();
|
virtual ~BBlockCache();
|
||||||
|
|||||||
@@ -37,11 +37,7 @@
|
|||||||
// are allocated than available, the variable fExcessBlocks is used to avoid
|
// are allocated than available, the variable fExcessBlocks is used to avoid
|
||||||
// growing the pool of free buffers
|
// growing the pool of free buffers
|
||||||
|
|
||||||
// XXX the BeBook describes the first parameter of the constructor as
|
BBlockCache::BBlockCache(uint32 blockCount,
|
||||||
// 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,
|
|
||||||
size_t blockSize,
|
size_t blockSize,
|
||||||
uint32 allocationType)
|
uint32 allocationType)
|
||||||
: fFreeList(0),
|
: fFreeList(0),
|
||||||
@@ -51,9 +47,6 @@ BBlockCache::BBlockCache(size_t cacheSize,
|
|||||||
fAlloc(0),
|
fAlloc(0),
|
||||||
fFree(0)
|
fFree(0)
|
||||||
{
|
{
|
||||||
if (cacheSize < blockSize)
|
|
||||||
debugger("Error, you can't create a BBlockCache with cacheSize < blockSize\n");
|
|
||||||
|
|
||||||
switch (allocationType) {
|
switch (allocationType) {
|
||||||
case B_OBJECT_CACHE:
|
case B_OBJECT_CACHE:
|
||||||
fAlloc = &operator new[];
|
fAlloc = &operator new[];
|
||||||
@@ -71,10 +64,13 @@ BBlockCache::BBlockCache(size_t cacheSize,
|
|||||||
// large enough to contain the _FreeBlock struct that is used.
|
// large enough to contain the _FreeBlock struct that is used.
|
||||||
if (blockSize < sizeof(_FreeBlock))
|
if (blockSize < sizeof(_FreeBlock))
|
||||||
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
|
// create blocks and put them into the free list
|
||||||
int count = cacheSize / blockSize;
|
for (int32 i = 0; i < (int32)blockCount; i++) {
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
_FreeBlock *block = reinterpret_cast<_FreeBlock *>(fAlloc(blockSize));
|
_FreeBlock *block = reinterpret_cast<_FreeBlock *>(fAlloc(blockSize));
|
||||||
if (!block)
|
if (!block)
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user