Remove R3 compatibility details from BPropertyInfo, fix memory leak and implement endian-ness

aware flatten and unflatten code.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@844 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
jrand 2002-08-21 06:44:27 +00:00
parent c42d33e7ca
commit e39c71fce8
3 changed files with 291 additions and 283 deletions

View File

@ -5,6 +5,7 @@
/ Description: Utility class for maintain scripting information / Description: Utility class for maintain scripting information
/ /
/ Copyright 1997-98, Be Incorporated, All Rights Reserved / Copyright 1997-98, Be Incorporated, All Rights Reserved
/ Modified for use with OpenBeOS.
/ /
*******************************************************************************/ *******************************************************************************/
@ -16,12 +17,28 @@
#include <Flattenable.h> #include <Flattenable.h>
#include <TypeConstants.h> /* For convenience */ #include <TypeConstants.h> /* For convenience */
/*
* The following define is used to turn off a number of member functions
* and member variables in BPropertyInfo which are only there to faciliate
* BeOS R3 compatibility. Be changed the property_info structure between
* R3 and R4 and these functions ensure that BPropertyInfo is backward
* compatible. However, between R3 and R4, Be changed the Intel executable
* format so R4 was not backward compatible with R3.
*
* Because OpenBeOS is only targetting Intel platform compatibility at this
* time, there is no need for R3 compatibility in OpenBeOS. By default
* these members will be turned off with the R3_COMPATIBLE define.
*/
#undef R3_COMPATIBLE
#ifdef R3_COMPATIBLE
struct _oproperty_info_;
#endif
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/*----- the property_info structure ------------------------------*/ /*----- the property_info structure ------------------------------*/
struct _oproperty_info_;
struct compound_type { struct compound_type {
struct field_pair { struct field_pair {
char *name; // name of entry in message char *name; // name of entry in message
@ -103,29 +120,30 @@ virtual void _ReservedPropertyInfo4();
BPropertyInfo(const BPropertyInfo &); BPropertyInfo(const BPropertyInfo &);
BPropertyInfo &operator=(const BPropertyInfo &); BPropertyInfo &operator=(const BPropertyInfo &);
void FreeMem(); void FreeMem();
void FreeInfoArray(property_info *p, int32);
void FreeInfoArray(value_info *p, int32);
void FreeInfoArray(_oproperty_info_ *p, int32);
static property_info *ConvertToNew(const _oproperty_info_ *p);
static _oproperty_info_ *ConvertFromNew(const property_info *p);
property_info *fPropInfo; property_info *fPropInfo;
value_info *fValueInfo; value_info *fValueInfo;
int32 fPropCount; int32 fPropCount;
bool fInHeap; bool fInHeap;
bool fOldInHeap;
uint16 fValueCount; uint16 fValueCount;
#ifndef R3_COMPATIBLE
uint32 _reserved[4];
#else
_oproperty_info_ *fOldPropInfo; _oproperty_info_ *fOldPropInfo;
bool fOldInHeap;
uint32 _reserved[2]; /* was 4 */ uint32 _reserved[2]; /* was 4 */
/* Deprecated */ /* Deprecated */
private: private:
static property_info *ConvertToNew(const _oproperty_info_ *p);
static _oproperty_info_ *ConvertFromNew(const property_info *p);
const property_info *PropertyInfo() const; const property_info *PropertyInfo() const;
BPropertyInfo(property_info *p, BPropertyInfo(property_info *p,
bool free_on_delete); bool free_on_delete);
static bool MatchCommand(uint32, int32, property_info *); static bool MatchCommand(uint32, int32, property_info *);
static bool MatchSpecifier(uint32, property_info *); static bool MatchSpecifier(uint32, property_info *);
#endif
}; };
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/

View File

@ -64,6 +64,38 @@ virtual void _ReservedPositionIO4();
int32 _reserved[2]; int32 _reserved[2];
}; };
class BMemoryIO : public BPositionIO {
public:
BMemoryIO(void *p, size_t len);
BMemoryIO(const void *p, size_t len);
virtual ~BMemoryIO();
virtual ssize_t ReadAt(off_t pos, void *buffer, size_t size);
virtual ssize_t WriteAt(off_t pos, const void *buffer, size_t size);
virtual off_t Seek(off_t pos, uint32 seek_mode);
virtual off_t Position() const;
virtual status_t SetSize(off_t size);
/*----- Private or reserved ---------------*/
private:
virtual void _ReservedMemoryIO1();
virtual void _ReservedMemoryIO2();
BMemoryIO(const BMemoryIO &);
BMemoryIO &operator=(const BMemoryIO &);
bool fReadOnly;
char *fBuf;
size_t fLen;
size_t fPhys;
size_t fPos;
int32 _reserved[1];
};
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/ /*-------------------------------------------------------------*/

View File

@ -30,8 +30,11 @@
#include <PropertyInfo.h> #include <PropertyInfo.h>
#include <Message.h> #include <Message.h>
#include <Errors.h> #include <Errors.h>
#include <ByteOrder.h>
#include <DataIO.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
// Project Includes ------------------------------------------------------------ // Project Includes ------------------------------------------------------------
@ -48,9 +51,7 @@ BPropertyInfo::BPropertyInfo(property_info *p, value_info *ci,
fValueInfo(ci), fValueInfo(ci),
fPropCount(0), fPropCount(0),
fInHeap(free_on_delete), fInHeap(free_on_delete),
fOldInHeap(false), fValueCount(0)
fValueCount(0),
fOldPropInfo(NULL)
{ {
if (fPropInfo) if (fPropInfo)
{ {
@ -67,14 +68,7 @@ BPropertyInfo::BPropertyInfo(property_info *p, value_info *ci,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BPropertyInfo::~BPropertyInfo() BPropertyInfo::~BPropertyInfo()
{ {
if (fInHeap) FreeMem();
{
if (fPropInfo)
delete fPropInfo;
if (fValueInfo)
delete fValueInfo;
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int32 BPropertyInfo::FindMatch(BMessage *msg, int32 index, BMessage *spec, int32 BPropertyInfo::FindMatch(BMessage *msg, int32 index, BMessage *spec,
@ -85,37 +79,12 @@ int32 BPropertyInfo::FindMatch(BMessage *msg, int32 index, BMessage *spec,
while ((fPropInfo != NULL) && (fPropInfo[property_index].name)) { while ((fPropInfo != NULL) && (fPropInfo[property_index].name)) {
property_info *propInfo = fPropInfo + property_index; property_info *propInfo = fPropInfo + property_index;
if (strcmp(propInfo->name, prop) == 0) { if ((strcmp(propInfo->name, prop) == 0) &&
int32 specifier_index = 0; (FindCommand(msg->what, index, propInfo)) &&
bool wildcardSpecifier = (propInfo->specifiers[0] == 0); (FindSpecifier(form, propInfo))) {
bool wildcardCommand = (propInfo->commands[0] == 0); if (data)
bool foundSpecifier = false; *((uint32*)data) = propInfo->extra_data;
bool foundCommand = false; return property_index;
for (int32 i = 0; i < 10 && propInfo->specifiers[i] != 0; i++) {
if (propInfo->specifiers[i] == form) {
foundSpecifier = true;
break;
}
}
for (int32 j = 0; j < 10 && propInfo->commands[j] != 0; j++) {
if (propInfo->commands[j] == msg->what) {
foundCommand = true;
break;
}
}
if (((index == 0) &&
(wildcardSpecifier || foundSpecifier) &&
(wildcardCommand || foundCommand)) ||
((index != 0) &&
(wildcardSpecifier || foundSpecifier) &&
(wildcardCommand))) {
if (data)
*((uint32*)data) = propInfo->extra_data;
return property_index;
}
} }
property_index++; property_index++;
} }
@ -212,91 +181,83 @@ status_t BPropertyInfo::Flatten(void *buffer, ssize_t numBytes) const
if (buffer == NULL) if (buffer == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
union BMemoryIO flatData(buffer, numBytes);
{
char *charPtr; char tmpChar = B_HOST_IS_BENDIAN;
uint32 *intPtr; int32 tmpInt;
uint16 *wrdPtr;
}; flatData.Write(&tmpChar, sizeof(tmpChar));
flatData.Write(&fPropCount, sizeof(fPropCount));
charPtr = (char*)buffer; tmpInt = 0x01 | (fValueInfo ? 0x2 : 0x0);
flatData.Write(&tmpInt, sizeof(tmpInt));
*(charPtr++) = 0;
*(intPtr++) = CountProperties(); if (fPropInfo) { // Main chunks
*(intPtr++) = 0x01 | (fValueInfo ? 0x2 : 0x0); for (int32 pi = 0; fPropInfo[pi].name != NULL; pi++) {
flatData.Write(fPropInfo[pi].name, strlen(fPropInfo[pi].name) + 1);
if (fPropInfo) if (fPropInfo[pi].usage != NULL) {
{ flatData.Write(fPropInfo[pi].usage, strlen(fPropInfo[pi].usage) + 1);
// Main chunks
for (int32 pi = 0; fPropInfo[pi].name != NULL; pi++)
{
strcpy(charPtr, fPropInfo[pi].name);
charPtr += strlen(fPropInfo[pi].name) + 1;
if (fPropInfo[pi].usage)
{
strcpy(charPtr, fPropInfo[pi].usage);
charPtr += strlen(fPropInfo[pi].usage) + 1;
} }
else else {
*(charPtr++) = 0; tmpChar = 0;
flatData.Write(&tmpChar, sizeof(tmpChar));
}
flatData.Write(&fPropInfo[pi].extra_data, sizeof(fPropInfo[pi].extra_data));
*(intPtr++) = fPropInfo[pi].extra_data; for (int32 i = 0; i < 10 && fPropInfo[pi].commands[i] != 0; i++) {
flatData.Write(&fPropInfo[pi].commands[i], sizeof(fPropInfo[pi].commands[i]));
for (int32 i = 0; i < 10 && fPropInfo[pi].commands[i] != 0; i++) }
*(intPtr++) = fPropInfo[pi].commands[i]; tmpInt = 0;
*(intPtr++) = 0; flatData.Write(&tmpInt, sizeof(tmpInt));
for (int32 i = 0; i < 10 && fPropInfo[pi].specifiers[i] != 0; i++) for (int32 i = 0; i < 10 && fPropInfo[pi].specifiers[i] != 0; i++) {
*(intPtr++) = fPropInfo[pi].specifiers[i]; flatData.Write(&fPropInfo[pi].specifiers[i], sizeof(fPropInfo[pi].specifiers[i]));
*(intPtr++) = 0; }
tmpInt = 0;
flatData.Write(&tmpInt, sizeof(tmpInt));
} }
// Type chunks // Type chunks
for (int32 pi = 0; fPropInfo[pi].name != NULL; pi++) for (int32 pi = 0; fPropInfo[pi].name != NULL; pi++) {
{ for (int32 i = 0; i < 10 && fPropInfo[pi].types[i] != 0; i++) {
for (int32 i = 0; i < 10 && fPropInfo[pi].types[i] != 0; i++) flatData.Write(&fPropInfo[pi].types[i], sizeof(fPropInfo[pi].types[i]));
*(intPtr++) = fPropInfo[pi].types[i]; }
*(intPtr++) = 0; tmpInt = 0;
flatData.Write(&tmpInt, sizeof(tmpInt));
for (int32 i = 0; i < 3 && fPropInfo[pi].ctypes[i].pairs[0].name != 0; i++) for (int32 i = 0; i < 3 && fPropInfo[pi].ctypes[i].pairs[0].name != 0; i++) {
{ for (int32 j = 0; j < 5 && fPropInfo[pi].ctypes[i].pairs[j].name != 0; j++) {
for (int32 j = 0; j < 5 && fPropInfo[pi].ctypes[i].pairs[j].name != 0; j++) flatData.Write(fPropInfo[pi].ctypes[i].pairs[j].name,
{ strlen(fPropInfo[pi].ctypes[i].pairs[j].name) + 1);
strcpy(charPtr, fPropInfo[pi].ctypes[i].pairs[j].name); flatData.Write(&fPropInfo[pi].ctypes[i].pairs[j].type,
charPtr += strlen(fPropInfo[pi].ctypes[i].pairs[j].name) + 1; sizeof(fPropInfo[pi].ctypes[i].pairs[j].type));
*(intPtr++) = fPropInfo[pi].ctypes[i].pairs[j].type;
} }
*(intPtr++) = 0; tmpInt = 0;
flatData.Write(&tmpInt, sizeof(tmpInt));
} }
*(intPtr++) = 0; tmpInt = 0;
flatData.Write(&tmpInt, sizeof(tmpInt));
} }
} }
if (fValueInfo) if (fValueInfo) {
{ // Value Chunks
// Chunks flatData.Write(&fValueCount, sizeof(fValueCount));
*(wrdPtr++) = CountValues(); for (int32 vi = 0; fValueInfo[vi].name != NULL; vi++) {
for (int32 vi = 0; fValueInfo[vi].name != NULL; vi++) flatData.Write(&fValueInfo[vi].kind, sizeof(fValueInfo[vi].kind));
{ flatData.Write(&fValueInfo[vi].value, sizeof(fValueInfo[vi].value));
*(intPtr++) = fValueInfo[vi].kind; flatData.Write(fValueInfo[vi].name, strlen(fValueInfo[vi].name) + 1);
*(intPtr++) = fValueInfo[vi].value; if (fValueInfo[vi].usage) {
flatData.Write(fValueInfo[vi].usage, strlen(fValueInfo[vi].usage) + 1);
strcpy(charPtr, fValueInfo[vi].name);
charPtr += strlen(fValueInfo[vi].name) + 1;
if (fValueInfo[vi].usage)
{
strcpy(charPtr, fValueInfo[vi].usage);
charPtr += strlen(fValueInfo[vi].usage) + 1;
} }
else else {
*(charPtr++) = 0; tmpChar = 0;
flatData.Write(&tmpChar, sizeof(tmpChar));
*(intPtr++) = fValueInfo[vi].extra_data; }
flatData.Write(&fValueInfo[vi].extra_data, sizeof(fValueInfo[vi].extra_data));
} }
} }
return B_OK; return B_OK;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -308,101 +269,124 @@ bool BPropertyInfo::AllowsTypeCode(type_code code) const
status_t BPropertyInfo::Unflatten(type_code code, const void *buffer, status_t BPropertyInfo::Unflatten(type_code code, const void *buffer,
ssize_t numBytes) ssize_t numBytes)
{ {
FreeMem();
if (!AllowsTypeCode(code)) if (!AllowsTypeCode(code))
return B_BAD_TYPE; return B_BAD_TYPE;
if (buffer == NULL) if (buffer == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
union FreeMem();
{
char *charPtr; BMemoryIO flatData(buffer, numBytes);
uint32 *intPtr; char tmpChar = B_HOST_IS_BENDIAN;
uint16 *wrdPtr; int32 tmpInt;
};
charPtr = ((char*)(buffer))+1; flatData.Read(&tmpChar, sizeof(tmpChar));
bool swapRequired = (tmpChar != B_HOST_IS_BENDIAN);
fPropCount = *(intPtr++);
int32 flags = *(intPtr++); flatData.Read(&fPropCount, sizeof(fPropCount));
if (flags & 1) int32 flags;
{ flatData.Read(&flags, sizeof(flags));
fPropInfo = new property_info[fPropCount + 1]; if (swapRequired) {
fPropCount = B_SWAP_INT32(fPropCount);
flags = B_SWAP_INT32(flags);
}
if (flags & 1) {
fPropInfo = static_cast<property_info *>(malloc(sizeof(property_info) * (fPropCount + 1)));
memset(fPropInfo, 0, (fPropCount + 1) * sizeof(property_info)); memset(fPropInfo, 0, (fPropCount + 1) * sizeof(property_info));
// Main chunks // Main chunks
for (int32 pi = 0; pi < fPropCount; pi++) for (int32 pi = 0; pi < fPropCount; pi++) {
{ fPropInfo[pi].name = strdup(static_cast<char *>(buffer) + flatData.Position());
fPropInfo[pi].name = strdup(charPtr); flatData.Seek(strlen(fPropInfo[pi].name) + 1, SEEK_CUR);
charPtr += strlen(fPropInfo[pi].name) + 1;
fPropInfo[pi].usage = strdup(static_cast<char *>(buffer) + flatData.Position());
flatData.Seek(strlen(fPropInfo[pi].usage) + 1, SEEK_CUR);
if (*charPtr) flatData.Read(&fPropInfo[pi].extra_data, sizeof(fPropInfo[pi].extra_data));
{ if (swapRequired) {
fPropInfo[pi].usage = strdup(charPtr); fPropInfo[pi].extra_data = B_SWAP_INT32(fPropInfo[pi].extra_data);
charPtr += strlen(fPropInfo[pi].usage) + 1; }
flatData.Read(&tmpInt, sizeof(tmpInt));
for (int32 i = 0; tmpInt != 0; i++) {
if (swapRequired) {
tmpInt = B_SWAP_INT32(tmpInt);
}
fPropInfo[pi].commands[i] = tmpInt;
flatData.Read(&tmpInt, sizeof(tmpInt));
}
flatData.Read(&tmpInt, sizeof(tmpInt));
for (int32 i = 0; tmpInt != 0; i++) {
if (swapRequired) {
tmpInt = B_SWAP_INT32(tmpInt);
}
fPropInfo[pi].specifiers[i] = tmpInt;
flatData.Read(&tmpInt, sizeof(tmpInt));
} }
else
charPtr++;
fPropInfo[pi].extra_data = *(intPtr++);
for (int32 i = 0; i < 10 && *intPtr; i++)
fPropInfo[pi].commands[i] = *(intPtr++);
intPtr++;
for (int32 i = 0; i < 10 && *intPtr; i++)
fPropInfo[pi].specifiers[i] = *(intPtr++);
intPtr++;
} }
// Type chunks // Type chunks
for (int32 pi = 0; pi < fPropCount; pi++) for (int32 pi = 0; pi < fPropCount; pi++) {
{ flatData.Read(&tmpInt, sizeof(tmpInt));
for (int32 i = 0; i < 10 && *intPtr; i++) for (int32 i = 0; tmpInt != 0; i++) {
fPropInfo[pi].types[i] = *(intPtr++); if (swapRequired) {
intPtr++; tmpInt = B_SWAP_INT32(tmpInt);
for (int32 i = 0; i < 3 && *intPtr; i++)
{
for (int32 j = 0; j < 5 && *intPtr; j++)
{
fPropInfo[pi].ctypes[i].pairs[j].name = strdup(charPtr);
charPtr += strlen(fPropInfo[pi].ctypes[i].pairs[j].name) + 1;
fPropInfo[pi].ctypes[i].pairs[j].type = *(intPtr++);
} }
intPtr++; fPropInfo[pi].types[i] = tmpInt;
flatData.Read(&tmpInt, sizeof(tmpInt));
}
flatData.Read(&tmpInt, sizeof(tmpInt));
for (int32 i = 0; tmpInt != 0; i++) {
for (int32 j = 0; tmpInt != 0; j++) {
flatData.Seek(-sizeof(tmpInt), SEEK_CUR);
fPropInfo[pi].ctypes[i].pairs[j].name =
strdup(static_cast<char *>(buffer) + flatData.Position());
flatData.Seek(strlen(fPropInfo[pi].ctypes[i].pairs[j].name) + 1, SEEK_CUR);
flatData.Read(&fPropInfo[pi].ctypes[i].pairs[j].type,
sizeof(fPropInfo[pi].ctypes[i].pairs[j].type));
if (swapRequired) {
fPropInfo[pi].ctypes[i].pairs[j].type =
B_SWAP_INT32(fPropInfo[pi].ctypes[i].pairs[j].type);
}
flatData.Read(&tmpInt, sizeof(tmpInt));
}
flatData.Read(&tmpInt, sizeof(tmpInt));
} }
intPtr++;
} }
} }
if (flags & 2) if (flags & 2) {
{ flatData.Read(&fValueCount, sizeof(fValueCount));
fValueCount = (int16)*(wrdPtr++); if (swapRequired) {
fValueCount = B_SWAP_INT16(fValueCount);
}
fValueInfo = new value_info[fValueCount + 1]; fValueInfo = static_cast<value_info *>(malloc(sizeof(value_info) * (fValueCount + 1)));
memset(fValueInfo, 0, (fValueCount + 1) * sizeof(value_info)); memset(fValueInfo, 0, (fValueCount + 1) * sizeof(value_info));
for (int32 vi = 0; vi < fValueCount; vi++) for (int32 vi = 0; vi < fValueCount; vi++)
{ {
fValueInfo[vi].kind = (value_kind)*(intPtr++); flatData.Read(&fValueInfo[vi].kind, sizeof(fValueInfo[vi].kind));
fValueInfo[vi].value = *(intPtr++); flatData.Read(&fValueInfo[vi].value, sizeof(fValueInfo[vi].value));
fValueInfo[vi].name = strdup(charPtr); fValueInfo[vi].name = strdup(static_cast<char *>(buffer) + flatData.Position());
charPtr += strlen(fValueInfo[vi].name) + 1; flatData.Seek(strlen(fValueInfo[vi].name) + 1, SEEK_CUR);
if (*charPtr)
{
fValueInfo[vi].usage = strdup(charPtr);
charPtr += strlen(fValueInfo[vi].usage) + 1;
}
else
charPtr++;
fValueInfo[vi].extra_data = *(intPtr++); fValueInfo[vi].usage = strdup(static_cast<char *>(buffer) + flatData.Position());
flatData.Seek(strlen(fValueInfo[vi].usage) + 1, SEEK_CUR);
flatData.Read(&fValueInfo[vi].extra_data, sizeof(fValueInfo[vi].extra_data));
if (swapRequired) {
fValueInfo[vi].kind = static_cast<value_kind>(B_SWAP_INT32(fValueInfo[vi].kind));
fValueInfo[vi].value = B_SWAP_INT32(fValueInfo[vi].value);
fValueInfo[vi].extra_data = B_SWAP_INT32(fValueInfo[vi].extra_data);
}
} }
} }
@ -466,27 +450,38 @@ void BPropertyInfo::PrintToStream() const
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool BPropertyInfo::FindCommand(uint32 what, int32, property_info *p) bool BPropertyInfo::FindCommand(uint32 what, int32 index, property_info *p)
{ {
//TODO: What's the second int32? bool result = false;
for (int32 i = 0; i < 10 && p->commands[i] != 0; i++)
{ if (p->commands[0] == 0) {
if (p->commands[i] == what) result = true;
return true; } else if (index == 0) {
for (int32 i = 0; i < 10 && p->commands[i] != 0; i++) {
if (p->commands[i] == what) {
result = true;
}
}
} }
return false; return(result);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool BPropertyInfo::FindSpecifier(uint32 form, property_info *p) bool BPropertyInfo::FindSpecifier(uint32 form, property_info *p)
{ {
for (int32 i = 0; i < 10 && p->specifiers[i] != 0; i++) bool result = false;
{
if (p->specifiers[i] == form) if (p->specifiers[0] == 0) {
return true; result = true;
} else {
for (int32 i = 0; i < 10 && p->specifiers[i] != 0; i++) {
if (p->specifiers[i] == form) {
result = true;
}
}
} }
return false; return(result);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BPropertyInfo::_ReservedPropertyInfo1() {} void BPropertyInfo::_ReservedPropertyInfo1() {}
@ -505,92 +500,55 @@ BPropertyInfo &BPropertyInfo::operator=(const BPropertyInfo &)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BPropertyInfo::FreeMem() void BPropertyInfo::FreeMem()
{ {
//TODO: Does this free all members from the class? int i, j, k;
if (fInHeap && fPropInfo)
{ if (!fInHeap) {
delete fPropInfo; return;
}
if (fPropInfo != NULL) {
for(i = 0; i < fPropCount; i++) {
if (fPropInfo[i].name != NULL) {
free(fPropInfo[i].name);
}
if (fPropInfo[i].usage != NULL) {
free(fPropInfo[i].usage);
}
for(j = 0; j < 3; j++) {
for(k = 0; k < 5; k++) {
if (fPropInfo[i].ctypes[j].pairs[k].name == NULL) {
break;
} else {
free(fPropInfo[i].ctypes[j].pairs[k].name);
}
}
if (fPropInfo[i].ctypes[j].pairs[0].name == NULL) {
break;
}
}
}
free(fPropInfo);
fPropInfo = NULL;
fPropCount = 0; fPropCount = 0;
} }
if (fInHeap && fValueInfo) if (fValueInfo != NULL) {
{ for(i = 0; i < fValueCount; i++) {
delete fValueInfo; if (fValueInfo[i].name != NULL) {
free(fValueInfo[i].name);
}
if (fValueInfo[i].usage != NULL) {
free(fValueInfo[i].usage);
}
}
free(fValueInfo);
fValueInfo = NULL;
fValueCount = 0; fValueCount = 0;
} }
fInHeap = false; fInHeap = false;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BPropertyInfo::FreeInfoArray(property_info *p, int32)
{
//TODO: Do we just have to delete the given ptr? What int32?
delete p;
}
//------------------------------------------------------------------------------
void BPropertyInfo::FreeInfoArray(value_info *p, int32)
{
//TODO: Do we just have to delete the given ptr? What int32?
delete p;
}
//------------------------------------------------------------------------------
void BPropertyInfo::FreeInfoArray(_oproperty_info_ *p, int32)
{
}
//------------------------------------------------------------------------------
property_info *BPropertyInfo::ConvertToNew(const _oproperty_info_ *p)
{
return NULL;
}
//------------------------------------------------------------------------------
_oproperty_info_ *BPropertyInfo::ConvertFromNew(const property_info *p)
{
return NULL;
}
//------------------------------------------------------------------------------
const property_info *BPropertyInfo::PropertyInfo() const
{
return fPropInfo;
}
//------------------------------------------------------------------------------
BPropertyInfo::BPropertyInfo(property_info *p, bool free_on_delete)
: fPropInfo(p),
fValueInfo(NULL),
fPropCount(0),
fInHeap(free_on_delete),
fOldInHeap(false),
fValueCount(0),
fOldPropInfo(NULL)
{
if (fPropInfo)
{
while (fPropInfo[fPropCount].name)
fPropCount++;
}
}
//------------------------------------------------------------------------------
bool BPropertyInfo::MatchCommand(uint32 what, int32, property_info *p)
{
//TODO: What's the second int32?
for (int32 i = 0; i < 10 && p->commands[i] != 0; i++)
{
if (p->commands[i] == what)
return true;
}
return false;
}
//------------------------------------------------------------------------------
bool BPropertyInfo::MatchSpecifier(uint32 form, property_info *p)
{
for (int32 i = 0; i < 10 && p->specifiers[i] != 0; i++)
{
if (p->specifiers[i] == form)
return true;
}
return false;
}
//------------------------------------------------------------------------------
/* /*
* $Log $ * $Log $