Re: gtk_tree_model_get ()
- From: "Hubert Sokolowski" <h sokolowski wsisiz edu pl>
- To: Tim Müller <zen18864 zen co uk>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gtk_tree_model_get ()
- Date: Tue, 11 Jan 2005 10:28:18 +0100 (CET)
On Tuesday 11 January 2005 08:58, Hubert Sokolowski wrote:
so as I understand that I have to free place_string_here, for example
gchar *s;
gtk_tree_model_get (model, &iter,
COLUMN_BLOCKED, &s,
-1);
if (s[0] == 'T')
s = "Odblokuj";
else
s = "Zablokuj";
g_free (s);
oops, I didn't see I was using the same variable s.
thanks for help.
but I get segmentation fault on g_free (s), and valgrind says
Invalid free()
Address 0x8068C2A is not stack'd, malloc'd or (recently) free'd
I want to know if I misunderstood the docs or the docs lies.
You are assigning a constant string to s and then free that - no wonder
it
segfaults on you. This will work:
gchar *s;
gtk_tree_model_get (model, &iter,
COLUMN_BLOCKED, &s,
-1);
g_print ("s = '%s'\n", s);
g_free (s);
This will segfault:
gchar *s;
s = "foobar";
g_free (s);
On a side note, s will be set to NULL by gtk_tree_model_get() if you
haven't
put a string into the model yet, so s[0] will segfault as well in case
you're
ever accessing an empty row/column).
ok, fixed, thanks a lot:).
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]