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
for it.
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,
guint *path_length_p,
gchar **path_p,
gchar **path_reversed_p)
{
static gchar *rev_path = NULL;
static guint path_len = 0;
guint len;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
len = 0;
do
{
gchar *string;
gchar *d, *s;
guint l;
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;
if (widget)
rev_path[len++] = '.';
else
rev_path[len++] = 0;
}
while (widget);
if (path_length_p)
*path_length_p = len - 1;
if (path_reversed_p)
*path_reversed_p = g_strdup (rev_path);
if (path_p)
{
*path_p = g_strdup (rev_path);
g_strreverse (*path_p);
}
g_free(rev_path);// I wonder if it will be useless to add this line.
}
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]