Re: GtkCombo - load list dynamically



On Sat, May 11, 2002 at 06:58:53PM -0700, Timbury wrote:
  while(!feof(fp))
  {
      if(fgets(line, 128, fp)) {
          printf("%p %s", line, line);
          combo1_items = g_list_append (combo1_items, line);

When you pass line to g_list_append, it does not (cannot) make a
copy.  So every entry in the list is a pointer to the same buffer,
which fgets overwrites every time through the loop.  

Pass a copy to g_list_append.

Andrew



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