You have to give memory for the pointer.
"name" is declared as a double pointer,so first allocate memory to the
pointer, and then for the element.

addrList.name = (char**) MemPtrNew (sizeof(void *) * addrList.total);
// "total" is the total pointers you want to declare,ie the number of names
 in the array

Now allocate memory for each element (in a for loop or, when required).

addrList.name[0]=(char*)MemPtrNew(StrLen(outbuffer)+1);
addrList.name[1]=(char*)MemPtrNew(StrLen(outbuffer)+1);
...
...
...
addrList.name[addrlist.total]=(char*)MemPtrNew(StrLen(outbuffer)+1);



>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Tim Lock <[EMAIL PROTECTED]> wrote:


I'm having trouble allocating memory for this structure.

char      outbuffer[1024];


typedef struct
{
     char **name;
     int       *idx;
     int       total;
}AddrRecord;

addrList.name[addrList.total]=(char*)MemPtrNew(StrLen(outbuffer)+1);

Is there any reason why i can't use the Mem Ptr or something to allocate
the memory?




      _____________________________________________________________

      Visit http://www.PalmGreetings.com The first & only Mobile greeting
      site.
      * You can send & receive e-cards using your Palm Pilot
      * View animated cards on your Palm
      * Draw your very own cards



-- 
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