Re: gtk+-1.2.10 has memory leak?
- From: "qn wang" <w_qn hotmail com>
- To: dhaude physnet uni-hamburg de
- Cc: gtk-list gnome org
- Subject: Re: gtk+-1.2.10 has memory leak?
- Date: Thu, 29 Jan 2004 12:26:14 +0800
I still want to ask something more about memory leak.
Here I get some source of a function from the gtkwidget.c.
Based on these source I wonder that maybe memory leak will happen,
because rev_path is not freed after using g_realloc() to allocate memory
And my suggestion to fix it is to add "g_free(rev_path);" at
the last line.
Sorry for bothering you some much times, but if I really has
some misunderstood here, would you be so kind to finger it out?
Thank you very much.
gtk_widget_class_path (GtkWidget *widget,
static gchar *rev_path = NULL;
static guint path_len = 0;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
len = 0;
gchar *d, *s;
string = gtk_type_name (GTK_WIDGET_TYPE (widget));
l = strlen (string);
while (path_len <= len + l + 1)
path_len += INIT_PATH_SIZE;
rev_path = g_realloc (rev_path, path_len);
s = string + l - 1;
d = rev_path + len;
while (s >= string)
*(d++) = *(s--);
len += l;
widget = widget->parent;
rev_path[len++] = '.';
rev_path[len++] = 0;
*path_length_p = len - 1;
*path_reversed_p = g_strdup (rev_path);
*path_p = g_strdup (rev_path);
g_free(rev_path);// I wonder if it will be useless to add this line.
与联机的朋友进行交流，请使用 MSN Messenger: http://messenger.msn.com/cn
] [Thread Prev