Re: [gtk-list] GSList



Hi Rich,

> I have a GSList list which points to gfloats. I can add them to it
> fine, but I can't recover the values!
> 
> This is actually giving me GCC warnings:
> 
> "warning: dereferencing `void *' pointer
> void value not ignored as it ought to be"
> 
> on the "xcurrent=(gfloat) *xptr;" line.

Use "xcurrent = *(gfloat*)xptr".

>   gpointer xptr;
>   for (j=0; j < g_slist_length(xlist); j++)
>   {
>     xptr=g_slist_nth_data(xlist, j);
>     xcurrent=(gfloat) *xptr;
>     // do things with xcurrent
>   }

This is VERY inefficient. Use the following code

GSList cur;
for (cur = xlist; cur; cur = g_slist_next (cur))
{
  xcurrent = *(gfloat*)cur->data;;
  // do things with xcurrent
}

Bye,
Sebastian
-- 
Sebastian Wilhelmi                   |            här ovanför alla molnen
mailto:wilhelmi@ira.uka.de           |     är himmlen så förunderligt blå
http://goethe.ira.uka.de/~wilhelmi   |



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