Re: (gtk_pixmap_new): assertion `val != NULL' failed
- From: lah micropp se (Lars Hallberg)
- To: Ronald Bultje <rbultje ronald bitfreak net>
- Cc: gtk-list gnome org
- Subject: Re: (gtk_pixmap_new): assertion `val != NULL' failed
- Date: Thu, 7 Jun 2001 13:59:34 +0200
On Thu, Jun 07, 2001 at 01:42:54PM +0200, Ronald Bultje wrote:
>
> ---
> #include "image.xpm"
> void create_pixmap(GtkWidget *w) {
> GdkPixmap *pixmap;
> GdkBitmap *mask;
> pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL,
> gtk_widget_get_default_colormap(),
> &mask, NULL, (gchar **)image_xpm);
> w = gtk_pixmap_new (pixmap, mask);
> }
> void test() {
> GtkWidget *w = NULL;
> create_pixmap(w);
> if (w == NULL) g_print("I am stupid\n");
> else g_print("I am not that stupid\n");
> }
> ---
>
> Should return "I am not that stupid", right? (I don't have a xwindows
> computer on my hands here so I can't test it - grom).
unless create_pixmap(w) is C++ with an referens argument this program
*will* output "I am stupid\n". In C, ther is *no* way the create_pixmap
funktion can change its argument. It can change the memory the pointer
points to (but then it have to be pointing to valid memory, not NULL),
but it can *not* change the pointer itself. So, i C, w is garanteed
to still point to NULL! You actuly have to send a pointer to a pointer
for the funktion to be able to change the pointer.
That is a poor interface tho, in C a initsilasion funktion (like fopen)
that returns a alocated chunk of memory whit a fiting pointer type is
commonly used.
/Lars
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]