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/