I think I should also note that I am using this list with a pop-up list.
Not sure if that makes a difference or not, but thought I would mention it.

tia,

Steve K

"Steve K" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Dave,
>
> Thank you for the advice.  I am having a real hard time dealing with
> Memhandles and char*s.  Been awhile since i'm done C programming and never
> played on a palm before.  Anyway, you have cleared things up quite a bit
> with your advice, however, I am still not getting the list to load.
>
> I have modified to the code to your suggestions as follows:
> (maybe I misread the ... but who knows)
>
> static char* gPlateString =
> "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0";
> static char** gListString;
> MemHandle gStringH;
>
> static Boolean PopulateList(void)
> {
>  FormType* frmP = FrmGetActiveForm();
>  ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc);
>
>  gStringH = SysFormPointerArrayToStrings(gPlateString, 6);
>  gListString = (char**)MemHandleLock(gStringH);
>
>  LstSetListChoices(lstP, gListString, 6);
>  LstDrawList(lstP);
>  MemHandleUnlock(gStringH);
>
>  MemHandleFree(gStringH);
>
>  return true;
> }
>
> Also I hate to be too much of a bother, if you have any links to some good
> reading on the subject that might help me out as well.
>
> tia,
>
> Steve
>
>
> "Dave Carrigan" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> >
> > On Thu, Aug 07, 2003 at 11:46:16PM -0700, Steve K wrote:
> >
> > > I have read many a posts on this question, however, none seem to be
> working
> > > for me.  I have attempted to simplify this with no results.  I am no
> longer
> > > getting fatal exceptions, however nothing is happening.
> > >
> > > What is the key ingredient i'm missing here?
> > > static char* gPlateString =
> > > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0";
> > > static char** gListString;
> > >
> > > static Boolean PopulateList(void)
> > > {
> > >  FormType* frmP = FrmGetActiveForm();
> > >  ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc);
> > >
> > >  gListString = (char**) MemPtrNew(StrLen(gPlateString));
> >
> > This will create an array of 7 pointers. Why are you doing this, and
> > what information do you think that StrLen is telling you here?
> >
> > >  gListString = (char**) SysFormPointerArrayToStrings(gPlateString, 6);
> >
> > SysFormPointerArrayToStrings returns a MemHandle, not a char**
> > pointer. Coercing a MemHandle to a char** doesn't make it one.
> >
> > Second, you've now lost the pointer to the original chunk of memory you
> > allocated with MemPtrNew (you overwrote its value with the result of
> > SysFormPointerArrayToStrings). This is a memory leak because you'll
> > never be able to free that pointer.
> >
> > You should be doing
> >
> >   MemHandle h = SysFormPointerArrayToStrings(gPlateString, 6);
> >   gListString = (char**)MemHandleLock(h);
> >
> >   ...
> >
> >   MemHandleFree(h);
> >
> > --
> > Dave Carrigan
> > Seattle, WA, USA
> > [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
> > UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL
> >
> >
>
>
>
>



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

Reply via email to