Re: [Plib-users] Problem with setLabel, weirdness ensues.
Brought to you by:
sjbaker
From: cory b. <co...@gm...> - 2008-06-11 20:28:29
|
Thank you everyone, that fixed it. Cory On Wed, Jun 11, 2008 at 4:22 PM, Fay John F Dr CTR USAF 46 SK <joh...@eg...> wrote: > Sounds like I have one less thing to do this evening. > > Jan, thank you very much. > > John F. Fay > Technical Fellow > Jacobs Technology TEAS Group > 850-883-1294 > > -----Original Message----- > From: pli...@li... > [mailto:pli...@li...] On Behalf Of Jan > Reucker > Sent: Wednesday, June 11, 2008 3:21 PM > To: pli...@li... > Subject: Re: [Plib-users] Problem with setLabel, weirdness ensues. > > Am Wed, 11 Jun 2008 15:55:57 -0400 schrieb "cory barton" > <co...@gm...>: > > >> void init_pui_widgets( void ) { >> //unused variable bbb >> char bbb[ PUSTRING_MAX ]; //if I remove this setLabel() fails! >> char txt[ PUSTRING_MAX ]; >> puInit(); > > Hi, > > this won't work, because txt is only allocated on the stack (local > variable), and it will be destroyed at the end of the function. > Introducing bbb cures the problem because it pushes txt further down > on the stack, thus avoiding that it is overwritten by the rest of > your code. If you introduce another function that uses more stack > space, chances are that the above code won't work anymore. > > puObject::setLabel() does not copy the string; it just copies the > pointer to the string. Therefore you have to provide a buffer > that doesn't go out of scope as long as your widget exists. > > Kind regards, > Jan R. > > -- > Jan Reucker > email: jan dot reucker at web dot de > web: http://www.reucker-online.de > > ------------------------------------------------------------------------ > - > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > |