Re: Memory question

2005-09-29 Thread Przemysław Sitek
Dnia 2005-09-29 13:56, Christian Neumair napisał: Am Donnerstag, den 29.09.2005, 13:39 +0200 schrieb Przemysław Sitek: Dnia 2005-09-29 21:41, Colossus napisał: Ok, the correct way is to cast g_strerror to (char *): response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,G

Re: Memory question

2005-09-29 Thread Christian Neumair
Am Donnerstag, den 29.09.2005, 13:39 +0200 schrieb Przemysław Sitek: > Dnia 2005-09-29 21:41, Colossus napisał: > > Ok, > > > > the correct way is to cast g_strerror to (char *): > > > > response = ShowGtkMessageDialog (GTK_WINDOW > > (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_O

Re: Memory question

2005-09-29 Thread Przemysław Sitek
Dnia 2005-09-29 21:41, Colossus napisał: Ok, the correct way is to cast g_strerror to (char *): response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,(char *) g_strerror(errno)); This way i don't get any warning. But it's still incorrec

Re: Memory question

2005-09-29 Thread Christian Neumair
Am Donnerstag, den 29.09.2005, 12:42 +0200 schrieb Christian Neumair: > 1 foo (const void *bar); and > 2 foo (void **bar); Should have a void retval. Sorry for the confusion. -- Christian Neumair <[EMAIL PROTECTED]> ___ gtk-app-devel-list mailing lis

Re: Memory question

2005-09-29 Thread Christian Neumair
Am Mittwoch, den 28.09.2005, 21:44 -0400 schrieb Allin Cottrell: > On Wed, 28 Sep 2005, David Rosal wrote: > > > Allin Cottrell wrote: > > > >> gchar *text = g_strdup_printf("banana %d", i); > >> gtk_entry_set_text(GTK_ENTRY(entry), text); > >> g_free(text); > > > > Is the above code really safe?

Re: Memory question

2005-09-29 Thread Colossus
Ok, the correct way is to cast g_strerror to (char *): response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK,(char *) g_strerror(errno)); This way i don't get any warning. Colossus wrote: Hi, I did as you suggested me but gcc 3.4.3 give

Re: Memory question

2005-09-29 Thread Colossus
Hi, I did as you suggested me but gcc 3.4.3 gives me this warning: callbacks.c:605: warning: passing arg 5 of `ShowGtkMessageDialog' discards qualifiers from pointer target type and the line 605 is: response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,G

Re: Memory question

2005-09-29 Thread Christian Neumair
Am Mittwoch, den 28.09.2005, 10:58 +0200 schrieb David Rosal: > Colossus wrote: > > Am I doing the same ( memory leaking ) with g_strdup_printf ? Yes, of course. It also allocated new memory for you, but additionally merges the ith (where ith > 1) argument of the g_strdup_printf into the string as

Re: Memory question

2005-09-29 Thread Christian Neumair
Am Dienstag, den 27.09.2005, 17:53 +0200 schrieb David Rosal: > gtk_entry_set_text(GTK_ENTRY(entry), g_strdup("banana"); > > Am I leaking memory? (...) > My question is: Is that memory chunk free'd before the program exits? If I'm taken correctly, your OS is meant to free *all* memory you allocat

Re: Memory question

2005-09-28 Thread Allin Cottrell
On Wed, 28 Sep 2005, David Rosal wrote: Allin Cottrell wrote: gchar *text = g_strdup_printf("banana %d", i); gtk_entry_set_text(GTK_ENTRY(entry), text); g_free(text); Is the above code really safe? Yes! A function such as gtk_entry_set_text() is bound to make a copy of the string offered

Re: Memory question

2005-09-28 Thread David Rosal
Colossus wrote: Hi, Am I doing the same ( memory leaking ) with g_strdup_printf ? If so what is the better way to write the following code: ? response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, g_strdup_printf ("%s",g_strerror(er

Re: Memory question

2005-09-28 Thread Roger Leigh
David Rosal <[EMAIL PROTECTED]> writes: > Allin Cottrell wrote: > >> gchar *text = g_strdup_printf("banana %d", i); >> gtk_entry_set_text(GTK_ENTRY(entry), text); >> g_free(text); > > Is the above code really safe? > > You're passing the address of "text" to the function > gtk_entry_set_text(). N

Re: Memory question

2005-09-28 Thread Colossus
Hi, Am I doing the same ( memory leaking ) with g_strdup_printf ? If so what is the better way to write the following code: ? response = ShowGtkMessageDialog (GTK_WINDOW (MainWindow),GTK_DIALOG_MODAL,GTK_MESSAGE_ERROR,GTK_BUTTONS_OK, g_strdup_printf ("%s",g_strerror(errno)) );

Re: Memory question

2005-09-28 Thread Padraig O'Briain
David Rosal wrote: Allin Cottrell wrote: gchar *text = g_strdup_printf("banana %d", i); gtk_entry_set_text(GTK_ENTRY(entry), text); g_free(text); Is the above code really safe? You're passing the address of "text" to the function gtk_entry_set_text(). Next you g_free() that address, so

Re: Memory question

2005-09-28 Thread David Rosal
Allin Cottrell wrote: gchar *text = g_strdup_printf("banana %d", i); gtk_entry_set_text(GTK_ENTRY(entry), text); g_free(text); Is the above code really safe? You're passing the address of "text" to the function gtk_entry_set_text(). Next you g_free() that address, so AFAIK the memory manag

Re: Memory question

2005-09-27 Thread Allin Cottrell
On Tue, 27 Sep 2005, David Rosal wrote: I know this is a general C programming issue, but... It is a memory leak to call g_strdup() as argument to other function? For example, if I do this: gtk_entry_set_text(GTK_ENTRY(entry), g_strdup("banana"); Am I leaking memory? Yes, since the allocat

Re: Memory question

2005-09-27 Thread Tristan Van Berkom
David Rosal wrote: Hello. I know this is a general C programming issue, but... It is a memory leak to call g_strdup() as argument to other function? For example, if I do this: gtk_entry_set_text(GTK_ENTRY(entry), g_strdup("banana"); Am I leaking memory? AFAIK, the above code makes glib (via

Re: Memory question

2005-09-27 Thread HuamiSoft Hubert Sokolowski
On Tue, 27 Sep 2005 17:53:17 +0200 David Rosal <[EMAIL PROTECTED]> wrote: > Hello. > > I know this is a general C programming issue, but... > > It is a memory leak to call g_strdup() as argument to other function? > > For example, if I do this: > > gtk_entry_set_text(GTK_ENTRY(entry), g_strdup