The BlockArray class is now longer used, and strlcpy() is part of the Haiku kernel anyway.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14416 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-10-18 20:02:16 +00:00
parent a59b9afff0
commit 0bf62ebece
2 changed files with 0 additions and 115 deletions
@@ -70,89 +70,3 @@ sorted_array::Remove(off_t value)
return true;
}
// #pragma mark -
BlockArray::BlockArray(int32 blockSize)
:
fArray(NULL),
fBlockSize(blockSize),
fSize(0)
{
}
BlockArray::~BlockArray()
{
free(fArray);
}
int32
BlockArray::Find(off_t value)
{
if (fArray == NULL)
return -1;
return fArray->Find(value);
}
status_t
BlockArray::Insert(off_t value)
{
if (fArray == NULL || fArray->count + 1 > fMaxBlocks) {
sorted_array *array = (sorted_array *)realloc(fArray,fSize + fBlockSize);
if (array == NULL)
return B_NO_MEMORY;
if (fArray == NULL)
array->count = 0;
fArray = array;
fSize += fBlockSize;
fMaxBlocks = fSize / sizeof(off_t) - 1;
}
fArray->Insert(value);
return B_OK;
}
status_t
BlockArray::Remove(off_t value)
{
if (fArray == NULL)
return B_ENTRY_NOT_FOUND;
return fArray->Remove(value) ? B_OK : B_ENTRY_NOT_FOUND;
}
void
BlockArray::MakeEmpty()
{
if (fArray != NULL)
fArray->count = 0;
}
// #pragma mark -
extern "C" size_t
strlcpy(char *dest, char const *source, size_t length)
{
if (length == 0)
return strlen(source);
size_t i = 0;
for (; i < length - 1 && source[i]; i++)
dest[i] = source[i];
dest[i] = '\0';
return i + strlen(source + i);
}
@@ -34,33 +34,4 @@ sorted_array::Find(off_t value) const
return FindInternal(value,i) ? i : -1;
}
// The BlockArray reserves a multiple of "blockSize" and
// maintain array size for new entries.
// This is used for the in-memory log entries before they
// are written to disk.
class BlockArray {
public:
BlockArray(int32 blockSize);
~BlockArray();
int32 Find(off_t value);
status_t Insert(off_t value);
status_t Remove(off_t value);
void MakeEmpty();
int32 CountItems() const { return fArray != NULL ? fArray->count : 0; }
int32 BlocksUsed() const { return fArray != NULL ? ((fArray->count + 1) * sizeof(off_t) + fBlockSize - 1) / fBlockSize : 0; }
sorted_array *Array() const { return fArray; }
int32 Size() const { return fSize; }
private:
sorted_array *fArray;
int32 fBlockSize;
int32 fSize;
int32 fMaxBlocks;
};
#endif /* UTILITY_H */