Re: possible bug



On Wednesday 01 January 2003 22:28, Brett Nash wrote:
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;
}

this is part of a function to load the initial values from a mysql database 
into a list store and somestring is the default record selection. if i kluge 
the code around so that the default value (somestring) is set in the callback 
function, it never goes away. if i call the initial loading function from the 
callback function, things drop off in the bit bucket somewhere. while i'm 
stepping through all of the sql functions, all values and addresses are 
peachy-keen and wonderful, and when i return into the callback to invoke 
another function things are just fine, but when i go into and come back from 
gtk_main() anything that wasn't done inside an actual callback function goes 
away. another way i kluged around this, was to create a text entry widget to 
stuff the default value in. that works fine but seems like using a shotgun to 
kill mosquitos. but if that's what i have to do, then.... "a man's gotta do, 
what a man's gotta do..." ;>)
                while((row = mysql_fetch_row(result_set)) != NULL)
                {
                        some_other_string = row[0];
                        if(first_record_flag)
                        {
                                first_record_flag = FALSE;
                                somestring = some_other_string;
                        }
                        .
                        .
                        /* rest of tree loading stuff */
                        .
                        .
                }



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