Changed BBitmapStream to behave more like Be's implementation while still checking for bad input.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5211 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2003-10-30 12:32:25 +00:00
parent b8fdbb4fff
commit c9cccf232a
+10 -6
View File
@@ -131,12 +131,14 @@ BBitmapStream::~BBitmapStream()
status_t status_t
BBitmapStream::ReadAt(off_t pos, void *buffer, size_t size) BBitmapStream::ReadAt(off_t pos, void *buffer, size_t size)
{ {
if (!buffer || pos < 0) if (!fBitmap)
return B_BAD_VALUE;
if (!fBitmap || pos >= fSize)
return B_ERROR; return B_ERROR;
if (!size) if (!size)
return B_NO_ERROR; return B_NO_ERROR;
if (pos >= fSize)
return B_ERROR;
if (!buffer || pos < 0)
return B_BAD_VALUE;
size_t toRead; size_t toRead;
void *source; void *source;
@@ -182,10 +184,10 @@ BBitmapStream::ReadAt(off_t pos, void *buffer, size_t size)
status_t status_t
BBitmapStream::WriteAt(off_t pos, const void *data, size_t size) BBitmapStream::WriteAt(off_t pos, const void *data, size_t size)
{ {
if (!data || pos < 0 || pos > fSize)
return B_BAD_VALUE;
if (!size) if (!size)
return B_NO_ERROR; return B_NO_ERROR;
if (!data || pos < 0 || pos > fSize)
return B_BAD_VALUE;
ssize_t written = 0; ssize_t written = 0;
while (size > 0) { while (size > 0) {
@@ -384,8 +386,10 @@ BBitmapStream::DetachBitmap(BBitmap **outBitmap)
{ {
if (!outBitmap) if (!outBitmap)
return B_BAD_VALUE; return B_BAD_VALUE;
if (fDetached || !fBitmap) if (!fBitmap || fDetached) {
*outBitmap = NULL;
return B_ERROR; return B_ERROR;
}
fDetached = true; fDetached = true;
*outBitmap = fBitmap; *outBitmap = fBitmap;