Re: (Easy?) Newbie enquiry re: pointers



On Tue, Oct 10, 2006 at 01:58:20PM -0400, Samuel Cormier-Iijima wrote:
Whenever you set the text, the widgets will keep copies of the text
for themselves. (they duplicated the string so it's not showing the
actual contents of *your* string). To update it, you'll have to set
the text again for the widgets. :-(

Correct, although the :-( is rather misplaced, because this
is a *good* thing.

Consider the widget just takes your string.  It still
doesn't know you are modifying the contents so you still
have to use some sort of explicit notification.  Not
speaking about changes in length that require memory
reallocation.  Not speaking about locking when some widget's
function could be executed while you are modifying the
string...

In other words, plain C strings typically have only one
owner (at any time point) who can modify it and who is
responsible for freeing the string because other approaches
are hard to get right.  The ownwer is either you or the
widget, not both.

Yeti


--
Whatever.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]