--- raju raya wrote:

>  P=  (PackDetails *)MemHandleLock(h);
>  const char * s=  (P->name);
>  Details * sample = (Details
>  *)MemPtrNew(sizeof(Details));
>  sample->ID=  P->ID;
>  sample->name = s;
>  s+= StrLen(s)+1;
>  sample->address = s;
>  MemPtrFree(  sample) ;       
>  MemHandleUnlock(h);                          


1. After you do MemPtrFree(sample), you can't expect
sample to contain anything useful.  I don't understand
what you are thinking here.

2. It's ok to modify s to point to different locations
in your packed string, but instead of assigning the
address of one string to another pointer, usually you
should copy a string like this:

  StrCopy(sample->name, s);

Here's how to unpack your packed data (this is
untested code, but it is very likely to be correct):

 typedef struct
 {
   UInt16 ID;
   Char * name;
   Char * address;
 } Details;
 typedef struct
 {
   UInt16 ID;
   Char name[1];
 } PackDetails;
 Char * s;
 PackDetails * P;
 Details details;

 // after setting up P:

 details.ID = P->ID;
 s = P->name;
 StrCopy(details.name, s);
 s += (StrLen(details.name)+1);
 StrCopy(details.address, s);


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

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

Reply via email to