Re: possible bug
- From: Brett Nash <nash nash nu>
- To: Jeffrey Goddard <moosewood mooseroot org>
- Cc: Harring Figueiredo <harringf yahoo com>,	GTK Apps Devel List <gtk-app-devel-list gnome org>
- Subject: Re: possible bug
- Date: Thu, 2 Jan 2003 15:28:57 +1100
How is some_other_string allocated then?  Remember C pointers emulate
references - so somestring and some_other_string both refer to the same
string.  If some_other_string is free'd somestring will be as well.
However unless you manually update the somestring, the pointer will be
pointing to an invalid address.
        nash
* Jeffrey Goddard <moosewood mooseroot org> wrote:
gchar *somestring;
void
some_callback_function(widget, user_data)
{
      somestring = some_other_string;
}
as long as this is done in a callback function, the string stays. if it is 
done in a function that is not a callback function, when the program goes 
into the gtk_main() loop the string is cleared(?) to a null string. the 
address of the pointer is still the same, but the data is off in the bit 
bucket somewhere. i used the term initializing incorrectly in this context. i 
am actually assigning values from a MySQL database, and it's the initial 
loading of all the variables.
Jeffrey
On Wednesday 01 January 2003 14:48, Harring Figueiredo wrote:
 If you post your coded snipet it would help us find the problem.
 What do you mean by initializing ?
 foo(){
 gchar*  c =  "something" ;
}
  foo(){
  gchar* c = strdup("something");
}
 Both initialize, but have different memory context.
 Again, posting the code would help.
Harring.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
-- 
Brett Nash <nash nash nu>
Sometimes it's better to light a flamethrower than curse the darkness.
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]