[Charset ISO-8859-1 unsupported, filtering to ASCII...] > Robert Moynihan wrote: > > > Hi Dean, > > > >> On Thu, 23 Mar 2006, Robert Moynihan wrote: > >> > >>> Actually, on second thought, I'm thinking that the problem might not be > >>> the call to LstSetListChoices at all. The ListType objects may > >>> still be > >>> invalid, but the bigger mistake would be that you allocated memory for > >>> the list elements within your FillLetsCookFormListWithData function(). > >>> As soon as you exit that function those memory allocations become > >>> invalid, so, when the list tries to draw (not AT the LstSetListChoices > >>> command, but probably shortly thereafter) it will crash. > >>> > >> > >> This isn't correct; the memory allocations the OP did were done with > >> MemPtrNew and MemHandleNew. Those don't become invalid on exit from the > >> function where they were done. > >> > >> Dean > >> > > But the OP declared them within the context of that function, so those > > variables (titleItemList, etc.) become invalid for use by the list > > after the function exits. > > > Err.... I see what you are saying. The memory allocations themselves > are not invalid after exiting the function, but the immediate reference > to them (the variable declarations) are. So the OP would have to be > careful to free that memory using pointers derived from the list itself.
True; good point. That is a good reason for using global variables to store pointers to allocated memory, at least if they're pointers one will need to free at some point. (I also suspect that Thomas Damme's message on this topic (to allocate StrLen(...)+1 rather than StrLen(...)) is more where the OP's problem lies.) Dean -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
