Re: Memory question



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,GTK_BUTTONS_OK,g_strerror(errno));

Colossus

Christian Neumair wrote:
Because g_strerror returns a const char * (meaning that you
may not/can't/don't have to free it, since your app doesn't own the
memory), you can simply call

ShowGtkMessageDialog (GTK_WINDOW (MainWindow),
                      GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
                      GTK_BUTTONS_OK,
                      g_strerror (errno));

without leaking anything.



--
Colossus

Cpsed, a Linux OpenGL 3D scene editor
http://cpsed.sourceforge.net/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]