Okay I've figured out a way around this issue but I still have no idea why
exactly it's occuring.  First of all "p" from the code below is declared as
MemPtr *.  If I declare a char * and use the following code instead of "p +=
sizeof(UrlRecord)", my app works properly:

cTemp = (char * ) p;
    cTemp += sizeof(UrlRecord);
    p = (MemPtr * ) cTemp;


It looks like even though the size of a UrlRecord is the same between the
two apps, doing "p += sizeof(UrlRecord)" actually increments the pointer too
far.  Is this because I'm working with a  MemPtr * instead of just a MemPtr?
I tried starting off with just a plain MemPtr but the "p +=" code throws a
compiler error in this case.


"Mark Biek" <[EMAIL PROTECTED]> wrote in message
news:82163@palm-dev-forum...
>
> I have one application that creates a database.  Each record in the
database
> is made up of these two structures:
>
> typedef struct FormProperty
> {
>  char propertyName[50];w
>  char propertyValue[255];
>  int x;
>  int y;
>  int w;
>  int h;
> }FormProperty;
>
> typedef struct UrlRecord
> {
>  char url[255];
>  int numProps;
> }UrlRecord;
>
> Basically the record form is <UrlRecord><FormProperty><FormProperty> with
an
> arbitrary number of form properties.  I have a whole set of functions for
> reading and writing these records and they all work nicely in the main
> application which creates the database.
>
> The problem I'm having now is that I have a second application that needs
to
> read these same functions so I've copied code from the first application
but
> it doesn't seem to be working.
>
> In order to read through each record I do something like the following:
>
> h = DmQueryRecord(dbPrefs,urlIndex);
>  p = MemHandleLock(h);
>
>  //The first item in the record is a UrlRecord object
>  urlRec=( UrlRecord *) p;
>
> //Move on the first FormProperty
> p += sizeof(UrlRecord);
> formProp= (FormProperty *) p;
>
> The portion of the code where I read the UrlRecord works in the second
> application but I get garbage when I increment the pointer to the
> FormProperty part of the record.
>
> Does anyone have any ideas why this might happen?  Thanks
>
> Mark
>
>
>
>



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

Reply via email to