Fixes for bugs in BFlattenable convenience functions (revealed by the new

unit tests).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3404 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz 2003-06-03 04:38:17 +00:00
parent c5d8f91d81
commit df1b8782c7

View File

@ -787,8 +787,12 @@ status_t BMessage::AddFlat(const char* name, BFlattenable* obj, int32 count)
char* buffer = new(nothrow) char[size];
if (buffer)
{
err = AddData(name, obj->TypeCode(), (void*)buffer, size,
obj->IsFixedSize(), count);
err = obj->Flatten((void*)buffer, size);
if (!err)
{
err = AddData(name, obj->TypeCode(), (void*)buffer, size,
obj->IsFixedSize(), count);
}
delete[] buffer;
}
else
@ -1147,7 +1151,11 @@ status_t BMessage::ReplaceFlat(const char* name, int32 index, BFlattenable* obj)
char* buffer = new(nothrow) char[size];
if (buffer)
{
err = ReplaceData(name, obj->TypeCode(), index, (void*)buffer, size);
err = obj->Flatten(buffer, size);
if (!err)
{
err = ReplaceData(name, obj->TypeCode(), index, (void*)buffer, size);
}
delete[] buffer;
}