On Mon, 22 Mar 1999, Danny Epstein wrote:
> At 2:29 PM -0800 3/22/1999, Michael S. Davis wrote:
> >Assume fixed length record (all strings same length).
> >Record:
> >|<--string2-->|<-double1->|<-double2->|<-string2->| just as an example
> >^
> >|____ pointer to record data: UInt dataPtr;
> >
<snipped>
> If you declare your record format as a struct, the compiler will add a pad byte
>after string2 if necessary to put double1 at an even offset within the record. In
>this case, you can compare in place by casting the record pointers into struct
>pointers. OTOH, if you compress and decompress the data yourself, avoiding the
>padding, you'll have to use MemMove to get the doubles to be at even addresses before
>you can compare them. In this case, you should rearrange your record format so the
>doubles are at the beginning. This should allow you to avoid the MemMoves. I have
>this on my own to-do list for the app I'm working on.
Now I'm confused again. I thought this was supposed to get easier:-)
I use a structure:
typedef struct {
string string1[20];
double elem1;
double elem2;
string string2[8];
} RecordStruct;
RecordStruct rec;
Then I use a DmWrite(RecPointer, 0, &rec, sizeof(rec));
to write data to DB.
And I use MemMove(&rec, RecPointer, sizeof(rec));
to fill the structure.
Do I have to do anything to take into consideration
the possiblity of elem1 and elem2 falling on the wrong
boundaries, since I am using MemMove and DmWrite. Or, is
that handled automatically by DmWrite and MemMove.
Related question. The sizeof(rec) produces a value. Is
that the same size as the data in the DB? It seems to be but
my string arrays are even in size and maybe that is a
coincidence.
Thanks
----------------------------------------------------
Shoot-to-Win
Protect the 2nd Amendment
----------------------------------------------------