Re: Memory question
- From: Colossus <colossus 3000 it>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Memory question
- Date: Thu, 29 Sep 2005 12:41:20 -0700
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 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]