cpssband cpssband <[EMAIL PROTECTED]> writes:

> typedef struct { 
>  char           *fields[FieldsCount]; 
>  BitmapPtr   Graphic
> } TestDBRecordType;

You can't use a BitmapPtr. That tells the compiler that Graphic is a
4-byte value that points to a BitmapType somewhere else in memory. For
that matter, your first entry (*fields) is also not going to work,
because you've declared an array of pointers. 

You could save those records, and reload them in the same run of the
application, and your pointers would still be valid (assuming that you
didn't free them between the save and the load). However, the next time
you run the application and load the record, all those pointers are
going to be pointing to uninitialized memory.

You need to rethink how you are going to store your data. You could do
something like

typedef struct {
   char fields[FieldsCount][maxFieldSize];
   BitmapType Graphic;
} TestDBRecordType;

This is an inefficient use of storage, since there most of the fields
are probably not maxed out at maxFieldSize, so you have some wasted
bytes there. You will probably want to think of an alternate storage
mechanism such as packed strings for the fields.

Also keep in mind that the compiler doesn't know the true size of the
bitmap in a BitmapType, because the bits are actually stored in the
space after the header defined by the BitmapType struct, so you have to
keep that in mind when you DmWrite the record to the database. 

Also note that as of the 4.0r1 SDK, you can't use BitmapType in a struct
any more because the BitmapType's internals have been hidden. If you
absolutely have to store a BitmapType in a database, make sure you
really understand how bitmaps are implemented in PalmOS. 

For your particular application, your record struct is probably going to
end up looking like

typedef struct {
  // possibly some fixed-storage headers here
  UInt8 data[1];
} TestDBRecordType;

typedef struct {
  // the same fixed-storage headers
  char *fields[FieldsCount];
  BitmapPtr Graphic;
} UnpackedTestDBRecordType;

Your database access routines are going to have to handle setting up the
pointers in the UnpackedTestDBRecordType so that they point to the
proper bytes in the TestDBRecordType's data member.

-- 
Dave Carrigan ([EMAIL PROTECTED])            | Yow! With this weapon I can
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-DNS | expose fictional characters and
Seattle, WA, USA                            | bring about sweeping reforms!!
http://www.rudedog.org/                     | 

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to