> struct{
> UInt16 id
> char * field1
> char* field2
> }test
This structure has pointers for field1 and field2, so you'd need to store
the actual contents of these fields somewhere. You wouldn't want to store a
struct like this directly in a database record, but it could be useful for a
temporary unpacked representation.
> isn't one database record saved like
> Address x: id
> Address y: field1
> Address z: field2
>
> whereas z = y + strLen(field1) ?
Not if you use the above struct. Also, don't forget to add one for the null
terminator.
> So, where is the big advantage to pack everything to
> a new structure
> struct{
> UInt16 id
> char fields[1]
> }packedtest
This is one possible declaration you could use for storing a packed record,
but the packing format is actually in the code that packs and unpacks
records, not in the struct itself.
The alternative, an unpacked struct, would look something like this:
struct{
UInt16 id;
Char field1[maxSize1];
Char field2[maxSize2];
}
This obviously wastes space if the actual contents of field1 and field2 tend
to be smaller than the maximum allowed values.
--
Danny @ PalmSource
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/