BPicture: Style fixes related to documentation.
Mostly pointer style adjustments
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2009, Haiku, Inc. All rights reserved.
|
* Copyright 2001-2014 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _PICTURE_H
|
#ifndef _PICTURE_H
|
||||||
@@ -20,13 +20,12 @@ class BPicture : public BArchivable {
|
|||||||
public:
|
public:
|
||||||
BPicture();
|
BPicture();
|
||||||
BPicture(const BPicture& other);
|
BPicture(const BPicture& other);
|
||||||
BPicture(BMessage* archive);
|
BPicture(BMessage* data);
|
||||||
virtual ~BPicture();
|
virtual ~BPicture();
|
||||||
|
|
||||||
static BArchivable* Instantiate(BMessage* archive);
|
static BArchivable* Instantiate(BMessage* data);
|
||||||
virtual status_t Archive(BMessage* archive,
|
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||||
bool deep = true) const;
|
virtual status_t Perform(perform_code code, void* arg);
|
||||||
virtual status_t Perform(perform_code d, void* arg);
|
|
||||||
|
|
||||||
status_t Play(void** callBackTable,
|
status_t Play(void** callBackTable,
|
||||||
int32 tableEntries,
|
int32 tableEntries,
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku Inc.
|
* Copyright 2001-2014 Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Marc Flerackers ([email protected])
|
* Marc Flerackers, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//! BPicture records a series of drawing instructions that can be "replayed" later.
|
|
||||||
|
// Records a series of drawing instructions that can be "replayed" later.
|
||||||
|
|
||||||
|
|
||||||
#include <Picture.h>
|
#include <Picture.h>
|
||||||
@@ -61,34 +62,33 @@ BPicture::Private::ReconnectToAppServer()
|
|||||||
|
|
||||||
|
|
||||||
struct _BPictureExtent_ {
|
struct _BPictureExtent_ {
|
||||||
_BPictureExtent_(const int32 &size = 0);
|
_BPictureExtent_(const int32& size = 0);
|
||||||
~_BPictureExtent_();
|
~_BPictureExtent_();
|
||||||
|
|
||||||
const void* Data() const { return fNewData; }
|
const void* Data() const { return fNewData; }
|
||||||
status_t ImportData(const void *data,
|
status_t ImportData(const void* data,
|
||||||
const int32 &size);
|
const int32& size);
|
||||||
|
|
||||||
status_t Flatten(BDataIO *stream);
|
status_t Flatten(BDataIO* stream);
|
||||||
status_t Unflatten(BDataIO *stream);
|
status_t Unflatten(BDataIO* stream);
|
||||||
|
|
||||||
int32 Size() const { return fNewSize; }
|
int32 Size() const { return fNewSize; }
|
||||||
status_t SetSize(const int32 &size);
|
status_t SetSize(const int32& size);
|
||||||
|
|
||||||
bool AddPicture(BPicture *picture)
|
bool AddPicture(BPicture* picture)
|
||||||
{ return fPictures.AddItem(picture); }
|
{ return fPictures.AddItem(picture); }
|
||||||
void DeletePicture(const int32 &index)
|
void DeletePicture(const int32& index)
|
||||||
{ delete static_cast<BPicture *>
|
{ delete static_cast<BPicture*>
|
||||||
(fPictures.RemoveItem(index)); }
|
(fPictures.RemoveItem(index)); }
|
||||||
|
|
||||||
BList* Pictures() { return &fPictures; }
|
BList* Pictures() { return &fPictures; }
|
||||||
BPicture* PictureAt(const int32 &index)
|
BPicture* PictureAt(const int32& index)
|
||||||
{ return static_cast<BPicture *>
|
{ return static_cast<BPicture*>
|
||||||
(fPictures.ItemAt(index)); }
|
(fPictures.ItemAt(index)); }
|
||||||
|
|
||||||
int32 CountPictures() const
|
int32 CountPictures() const
|
||||||
{ return fPictures.CountItems(); }
|
{ return fPictures.CountItems(); }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* fNewData;
|
void* fNewData;
|
||||||
int32 fNewSize;
|
int32 fNewSize;
|
||||||
@@ -115,7 +115,7 @@ BPicture::BPicture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPicture::BPicture(const BPicture &otherPicture)
|
BPicture::BPicture(const BPicture& otherPicture)
|
||||||
:
|
:
|
||||||
fToken(-1),
|
fToken(-1),
|
||||||
fExtent(NULL),
|
fExtent(NULL),
|
||||||
@@ -129,25 +129,27 @@ BPicture::BPicture(const BPicture &otherPicture)
|
|||||||
link.Attach<int32>(otherPicture.fToken);
|
link.Attach<int32>(otherPicture.fToken);
|
||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (link.FlushWithReply(status) == B_OK
|
if (link.FlushWithReply(status) == B_OK && status == B_OK)
|
||||||
&& status == B_OK)
|
|
||||||
link.Read<int32>(&fToken);
|
link.Read<int32>(&fToken);
|
||||||
|
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherPicture.fExtent->Size() > 0) {
|
if (otherPicture.fExtent->Size() > 0) {
|
||||||
fExtent->ImportData(otherPicture.fExtent->Data(), otherPicture.fExtent->Size());
|
fExtent->ImportData(otherPicture.fExtent->Data(),
|
||||||
|
otherPicture.fExtent->Size());
|
||||||
|
|
||||||
for (int32 i = 0; i < otherPicture.fExtent->CountPictures(); i++) {
|
for (int32 i = 0; i < otherPicture.fExtent->CountPictures(); i++) {
|
||||||
BPicture *picture = new BPicture(*otherPicture.fExtent->PictureAt(i));
|
BPicture* picture
|
||||||
|
= new BPicture(*otherPicture.fExtent->PictureAt(i));
|
||||||
fExtent->AddPicture(picture);
|
fExtent->AddPicture(picture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPicture::BPicture(BMessage *archive)
|
BPicture::BPicture(BMessage* data)
|
||||||
:
|
:
|
||||||
fToken(-1),
|
fToken(-1),
|
||||||
fExtent(NULL),
|
fExtent(NULL),
|
||||||
@@ -156,24 +158,26 @@ BPicture::BPicture(BMessage *archive)
|
|||||||
_InitData();
|
_InitData();
|
||||||
|
|
||||||
int32 version;
|
int32 version;
|
||||||
if (archive->FindInt32("_ver", &version) != B_OK)
|
if (data->FindInt32("_ver", &version) != B_OK)
|
||||||
version = 0;
|
version = 0;
|
||||||
|
|
||||||
int8 endian;
|
int8 endian;
|
||||||
if (archive->FindInt8("_endian", &endian) != B_OK)
|
if (data->FindInt8("_endian", &endian) != B_OK)
|
||||||
endian = 0;
|
endian = 0;
|
||||||
|
|
||||||
const void *data;
|
const void* pictureData;
|
||||||
int32 size;
|
int32 size;
|
||||||
if (archive->FindData("_data", B_RAW_TYPE, &data, (ssize_t*)&size) != B_OK)
|
if (data->FindData("_data", B_RAW_TYPE, &pictureData, (ssize_t*)&size)
|
||||||
|
!= B_OK) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Load sub pictures
|
// Load sub pictures
|
||||||
BMessage picMsg;
|
BMessage pictureMessage;
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
while (archive->FindMessage("piclib", i++, &picMsg) == B_OK) {
|
while (data->FindMessage("piclib", i++, &pictureMessage) == B_OK) {
|
||||||
BPicture *pic = new BPicture(&picMsg);
|
BPicture* picture = new BPicture(&pictureMessage);
|
||||||
fExtent->AddPicture(pic);
|
fExtent->AddPicture(picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version == 0) {
|
if (version == 0) {
|
||||||
@@ -198,7 +202,7 @@ BPicture::BPicture(BMessage *archive)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPicture::BPicture(const void *data, int32 size)
|
BPicture::BPicture(const void* data, int32 size)
|
||||||
{
|
{
|
||||||
_InitData();
|
_InitData();
|
||||||
// TODO: For now. We'll see if it's worth to support old style data
|
// TODO: For now. We'll see if it's worth to support old style data
|
||||||
@@ -244,46 +248,46 @@ BPicture::_DisposeData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BArchivable *
|
BArchivable*
|
||||||
BPicture::Instantiate(BMessage *archive)
|
BPicture::Instantiate(BMessage* data)
|
||||||
{
|
{
|
||||||
if (validate_instantiation(archive, "BPicture"))
|
if (validate_instantiation(data, "BPicture"))
|
||||||
return new BPicture(archive);
|
return new BPicture(data);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPicture::Archive(BMessage *archive, bool deep) const
|
BPicture::Archive(BMessage* data, bool deep) const
|
||||||
{
|
{
|
||||||
if (!const_cast<BPicture*>(this)->_AssertLocalCopy())
|
if (!const_cast<BPicture*>(this)->_AssertLocalCopy())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
status_t err = BArchivable::Archive(archive, deep);
|
status_t err = BArchivable::Archive(data, deep);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = archive->AddInt32("_ver", 1);
|
err = data->AddInt32("_ver", 1);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = archive->AddInt8("_endian", B_HOST_IS_BENDIAN);
|
err = data->AddInt8("_endian", B_HOST_IS_BENDIAN);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = archive->AddData("_data", B_RAW_TYPE, fExtent->Data(), fExtent->Size());
|
err = data->AddData("_data", B_RAW_TYPE, fExtent->Data(), fExtent->Size());
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
for (int32 i = 0; i < fExtent->CountPictures(); i++) {
|
for (int32 i = 0; i < fExtent->CountPictures(); i++) {
|
||||||
BMessage picMsg;
|
BMessage pictureMessage;
|
||||||
|
|
||||||
err = fExtent->PictureAt(i)->Archive(&picMsg, deep);
|
err = fExtent->PictureAt(i)->Archive(&pictureMessage, deep);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
err = archive->AddMessage("piclib", &picMsg);
|
err = data->AddMessage("piclib", &pictureMessage);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -293,26 +297,27 @@ BPicture::Archive(BMessage *archive, bool deep) const
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPicture::Perform(perform_code d, void *arg)
|
BPicture::Perform(perform_code code, void* arg)
|
||||||
{
|
{
|
||||||
return BArchivable::Perform(d, arg);
|
return BArchivable::Perform(code, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPicture::Play(void **callBackTable, int32 tableEntries, void *user)
|
BPicture::Play(void** callBackTable, int32 tableEntries, void* user)
|
||||||
{
|
{
|
||||||
if (!_AssertLocalCopy())
|
if (!_AssertLocalCopy())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
BPrivate::PicturePlayer player(fExtent->Data(), fExtent->Size(), fExtent->Pictures());
|
BPrivate::PicturePlayer player(fExtent->Data(), fExtent->Size(),
|
||||||
|
fExtent->Pictures());
|
||||||
|
|
||||||
return player.Play(callBackTable, tableEntries, user);
|
return player.Play(callBackTable, tableEntries, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPicture::Flatten(BDataIO *stream)
|
BPicture::Flatten(BDataIO* stream)
|
||||||
{
|
{
|
||||||
// TODO: what about endianess?
|
// TODO: what about endianess?
|
||||||
|
|
||||||
@@ -323,6 +328,7 @@ BPicture::Flatten(BDataIO *stream)
|
|||||||
ssize_t bytesWritten = stream->Write(&header, sizeof(header));
|
ssize_t bytesWritten = stream->Write(&header, sizeof(header));
|
||||||
if (bytesWritten < B_OK)
|
if (bytesWritten < B_OK)
|
||||||
return bytesWritten;
|
return bytesWritten;
|
||||||
|
|
||||||
if (bytesWritten != (ssize_t)sizeof(header))
|
if (bytesWritten != (ssize_t)sizeof(header))
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
|
|
||||||
@@ -331,7 +337,7 @@ BPicture::Flatten(BDataIO *stream)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPicture::Unflatten(BDataIO *stream)
|
BPicture::Unflatten(BDataIO* stream)
|
||||||
{
|
{
|
||||||
// TODO: clear current picture data?
|
// TODO: clear current picture data?
|
||||||
|
|
||||||
@@ -339,6 +345,7 @@ BPicture::Unflatten(BDataIO *stream)
|
|||||||
ssize_t bytesRead = stream->Read(&header, sizeof(header));
|
ssize_t bytesRead = stream->Read(&header, sizeof(header));
|
||||||
if (bytesRead < B_OK)
|
if (bytesRead < B_OK)
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
|
|
||||||
if (bytesRead != (ssize_t)sizeof(header)
|
if (bytesRead != (ssize_t)sizeof(header)
|
||||||
|| header.magic1 != 2 || header.magic2 != 0)
|
|| header.magic1 != 2 || header.magic2 != 0)
|
||||||
return B_BAD_TYPE;
|
return B_BAD_TYPE;
|
||||||
@@ -361,7 +368,7 @@ BPicture::Unflatten(BDataIO *stream)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPicture::_ImportOldData(const void *data, int32 size)
|
BPicture::_ImportOldData(const void* data, int32 size)
|
||||||
{
|
{
|
||||||
// TODO: We don't support old data for now
|
// TODO: We don't support old data for now
|
||||||
}
|
}
|
||||||
@@ -433,8 +440,8 @@ BPicture::_Upload()
|
|||||||
link.Attach<int32>(fExtent->CountPictures());
|
link.Attach<int32>(fExtent->CountPictures());
|
||||||
|
|
||||||
for (int32 i = 0; i < fExtent->CountPictures(); i++) {
|
for (int32 i = 0; i < fExtent->CountPictures(); i++) {
|
||||||
BPicture *picture = fExtent->PictureAt(i);
|
BPicture* picture = fExtent->PictureAt(i);
|
||||||
if (picture)
|
if (picture != NULL)
|
||||||
link.Attach<int32>(picture->fToken);
|
link.Attach<int32>(picture->fToken);
|
||||||
else
|
else
|
||||||
link.Attach<int32>(-1);
|
link.Attach<int32>(-1);
|
||||||
@@ -444,8 +451,9 @@ BPicture::_Upload()
|
|||||||
|
|
||||||
status_t status = B_ERROR;
|
status_t status = B_ERROR;
|
||||||
if (link.FlushWithReply(status) == B_OK
|
if (link.FlushWithReply(status) == B_OK
|
||||||
&& status == B_OK)
|
&& status == B_OK) {
|
||||||
link.Read<int32>(&fToken);
|
link.Read<int32>(&fToken);
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -469,23 +477,23 @@ BPicture::_Download()
|
|||||||
|
|
||||||
// Read sub picture tokens
|
// Read sub picture tokens
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
BPicture *pic = new BPicture;
|
BPicture* picture = new BPicture;
|
||||||
link.Read<int32>(&pic->fToken);
|
link.Read<int32>(&picture->fToken);
|
||||||
fExtent->AddPicture(pic);
|
fExtent->AddPicture(picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 size;
|
int32 size;
|
||||||
link.Read<int32>(&size);
|
link.Read<int32>(&size);
|
||||||
status = fExtent->SetSize(size);
|
status = fExtent->SetSize(size);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
link.Read(const_cast<void *>(fExtent->Data()), size);
|
link.Read(const_cast<void*>(fExtent->Data()), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const void *
|
const void*
|
||||||
BPicture::Data() const
|
BPicture::Data() const
|
||||||
{
|
{
|
||||||
if (fExtent->Data() == NULL)
|
if (fExtent->Data() == NULL)
|
||||||
@@ -506,7 +514,7 @@ BPicture::DataSize() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPicture::Usurp(BPicture *lameDuck)
|
BPicture::Usurp(BPicture* lameDuck)
|
||||||
{
|
{
|
||||||
_DisposeData();
|
_DisposeData();
|
||||||
|
|
||||||
@@ -518,10 +526,10 @@ BPicture::Usurp(BPicture *lameDuck)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPicture *
|
BPicture*
|
||||||
BPicture::StepDown()
|
BPicture::StepDown()
|
||||||
{
|
{
|
||||||
BPicture *lameDuck = fUsurped;
|
BPicture* lameDuck = fUsurped;
|
||||||
fUsurped = NULL;
|
fUsurped = NULL;
|
||||||
|
|
||||||
return lameDuck;
|
return lameDuck;
|
||||||
@@ -533,15 +541,15 @@ void BPicture::_ReservedPicture2() {}
|
|||||||
void BPicture::_ReservedPicture3() {}
|
void BPicture::_ReservedPicture3() {}
|
||||||
|
|
||||||
|
|
||||||
BPicture &
|
BPicture&
|
||||||
BPicture::operator=(const BPicture &)
|
BPicture::operator=(const BPicture&)
|
||||||
{
|
{
|
||||||
return *this;
|
return* this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _BPictureExtent_
|
// _BPictureExtent_
|
||||||
_BPictureExtent_::_BPictureExtent_(const int32 &size)
|
_BPictureExtent_::_BPictureExtent_(const int32& size)
|
||||||
:
|
:
|
||||||
fNewData(NULL),
|
fNewData(NULL),
|
||||||
fNewSize(0)
|
fNewSize(0)
|
||||||
@@ -554,12 +562,12 @@ _BPictureExtent_::~_BPictureExtent_()
|
|||||||
{
|
{
|
||||||
free(fNewData);
|
free(fNewData);
|
||||||
for (int32 i = 0; i < fPictures.CountItems(); i++)
|
for (int32 i = 0; i < fPictures.CountItems(); i++)
|
||||||
delete static_cast<BPicture *>(fPictures.ItemAtFast(i));
|
delete static_cast<BPicture*>(fPictures.ItemAtFast(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
_BPictureExtent_::ImportData(const void *data, const int32 &size)
|
_BPictureExtent_::ImportData(const void* data, const int32& size)
|
||||||
{
|
{
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -576,7 +584,7 @@ _BPictureExtent_::ImportData(const void *data, const int32 &size)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
_BPictureExtent_::Unflatten(BDataIO *stream)
|
_BPictureExtent_::Unflatten(BDataIO* stream)
|
||||||
{
|
{
|
||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -603,6 +611,7 @@ _BPictureExtent_::Unflatten(BDataIO *stream)
|
|||||||
bytesRead = stream->Read(&size, sizeof(size));
|
bytesRead = stream->Read(&size, sizeof(size));
|
||||||
if (bytesRead < B_OK)
|
if (bytesRead < B_OK)
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
|
|
||||||
if (bytesRead != (ssize_t)sizeof(size))
|
if (bytesRead != (ssize_t)sizeof(size))
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
|
|
||||||
@@ -616,6 +625,7 @@ _BPictureExtent_::Unflatten(BDataIO *stream)
|
|||||||
bytesRead = stream->Read(fNewData, size);
|
bytesRead = stream->Read(fNewData, size);
|
||||||
if (bytesRead < B_OK)
|
if (bytesRead < B_OK)
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
|
|
||||||
if (bytesRead != (ssize_t)size)
|
if (bytesRead != (ssize_t)size)
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
|
|
||||||
@@ -624,12 +634,13 @@ _BPictureExtent_::Unflatten(BDataIO *stream)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
_BPictureExtent_::Flatten(BDataIO *stream)
|
_BPictureExtent_::Flatten(BDataIO* stream)
|
||||||
{
|
{
|
||||||
int32 count = fPictures.CountItems();
|
int32 count = fPictures.CountItems();
|
||||||
ssize_t bytesWritten = stream->Write(&count, sizeof(count));
|
ssize_t bytesWritten = stream->Write(&count, sizeof(count));
|
||||||
if (bytesWritten < B_OK)
|
if (bytesWritten < B_OK)
|
||||||
return bytesWritten;
|
return bytesWritten;
|
||||||
|
|
||||||
if (bytesWritten != (ssize_t)sizeof(count))
|
if (bytesWritten != (ssize_t)sizeof(count))
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
|
|
||||||
@@ -642,12 +653,14 @@ _BPictureExtent_::Flatten(BDataIO *stream)
|
|||||||
bytesWritten = stream->Write(&fNewSize, sizeof(fNewSize));
|
bytesWritten = stream->Write(&fNewSize, sizeof(fNewSize));
|
||||||
if (bytesWritten < B_OK)
|
if (bytesWritten < B_OK)
|
||||||
return bytesWritten;
|
return bytesWritten;
|
||||||
|
|
||||||
if (bytesWritten != (ssize_t)sizeof(fNewSize))
|
if (bytesWritten != (ssize_t)sizeof(fNewSize))
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
|
|
||||||
bytesWritten = stream->Write(fNewData, fNewSize);
|
bytesWritten = stream->Write(fNewData, fNewSize);
|
||||||
if (bytesWritten < B_OK)
|
if (bytesWritten < B_OK)
|
||||||
return bytesWritten;
|
return bytesWritten;
|
||||||
|
|
||||||
if (bytesWritten != fNewSize)
|
if (bytesWritten != fNewSize)
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
|
|
||||||
@@ -656,7 +669,7 @@ _BPictureExtent_::Flatten(BDataIO *stream)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
_BPictureExtent_::SetSize(const int32 &size)
|
_BPictureExtent_::SetSize(const int32& size)
|
||||||
{
|
{
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -668,9 +681,10 @@ _BPictureExtent_::SetSize(const int32 &size)
|
|||||||
free(fNewData);
|
free(fNewData);
|
||||||
fNewData = NULL;
|
fNewData = NULL;
|
||||||
} else {
|
} else {
|
||||||
void *data = realloc(fNewData, size);
|
void* data = realloc(fNewData, size);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
fNewData = data;
|
fNewData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user