Re: g_slist and const



On Fri, 2007-03-09 at 19:46 +0100, Asbj�rote:
> I'm tightning my code and i wonder why some of the g_slist functions don't use 
> "const".
> 
> gint     g_slist_position  (GSList           *list,  GSList           *llink);
> gint     g_slist_index      (GSList           *list, gconstpointer     data);
> guint    g_slist_length    (GSList           *list);
> 
> Should be like this:
> gint     g_slist_position    (const GSList  *list, const GSList *llink);
> gint     g_slist_index        (const GSList   *list, gconstpointer     data);
> guint   g_slist_length      (const GSList   *list);
> 
> I have changed the code and glib compile without any problems.
> The change will be harmless, and the code will more readable.
> The documentation have to be changed then !
  
  const GSList *list = get_some_constant_list();
  GSList *l = g_slist_nth(list, 5);
  l->data = new_value;

Combining const and GSList/GList doesn't work well enough to be worth
supporting.
			
						- Owen








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