Write() Returns B_NO_MEMORY if it cant allocate memory

iVS: ----------------------------------------------------------------------


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1162 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2002-09-24 19:04:22 +00:00
parent 5da124ea94
commit c9ea158353

View File

@ -341,16 +341,18 @@ BMallocIO::WriteAt(off_t pos, const void *buffer, size_t size)
size_t newSize = max(pos + size, static_cast<off_t>(fLength));
if (newSize > fMallocSize)
if (SetSize(newSize) != B_OK)
size = 0;
status_t error = B_OK;
if (size > 0) {
if (newSize > fMallocSize)
error = SetSize(newSize);
if (error == B_OK) {
memcpy(fData + pos, buffer, size);
if (pos + size > fLength)
fLength = pos + size;
}
return size;
return error != B_OK ? error : size;
}