problem with memory leaks
- From: morph_in <atandon_b03 iiita ac in>
- To: gtk-list gnome org
- Subject: problem with memory leaks
- Date: Mon, 3 Apr 2006 03:19:25 -0700 (PDT)
Hi,
I am a newbie to GTK programming and cannot work out a simple problem ,so
pls can some one inform abt the problem
GtkTextBuffer *tbuffer;
GtkTextIter start;
GtkTextIter end;
GtkWidget * textv = lookup_widget(GTK_WIDGET(menuitem), "textview1");
tbuffer =gtk_text_view_get_buffer(textv);
FILE *infile;
infile = fopen("/root/Desktop/a.s", "r");
if (infile)
{
char buffer[1024];
int nchars;
gchar *utf8;
while (1)
{
nchars = fread(buffer, 1, 1024, infile);
utf8 = g_locale_to_utf8(buffer, nchars, NULL, NULL, NULL);
if (!utf8)
{ return;
}
gtk_text_buffer_get_end_iter(tbuffer, &end);
gtk_text_buffer_insert(tbuffer, &end, utf8, strlen(utf8));
if (nchars < 1024)
break;
}
fclose (infile);
free(utf8);
}
gtk_text_view_set_buffer(GTK_TEXT_VIEW(textv), tbuffer);
//g_free(tbuffer); //freeing any of them produces
segmentation fault
//g_free(textv); //and if i donot free them then i get a
15Kb leak
So basically what am i doing wrong and what is the correct way to free the
memory allocated .Hoping for a response
Thx
Regards
morph_in
--
View this message in context: http://www.nabble.com/problem-with-memory-leaks-t1386109.html#a3723082
Sent from the Gtk+ - General forum at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]