Re: [gtk-list] Re: potential problems with malloc/free vs. C++ new/delete ???




On Thu, 3 Dec 1998, Dave Reed wrote:
> Should I be freeing anything here after it gets added to the combo?
> What part of the documentation should I be looking in to find the
> answers to these kind of memory questions?
> 

You can look for a comment in the header files; other than that, you
pretty much have to read the source code for the function, and see if the
string is copied or kept. 

In the GtkCombo case, the string is used in this context:
  list = strings;
  while (list)
    {
      li = gtk_list_item_new_with_label ((gchar *) list->data);
      gtk_widget_show (li);
      gtk_container_add (GTK_CONTAINER (combo->list), li);
      list = list->next;
    }

gtk_list_item_new_with_label() copies the string I think, so you are
responsible for freeing it. (I think Gtk probably is consistent about
copying strings rather than using the ones you pass in, at least I can't
think of an exception right now.)

Someday we will have documentation. :-)

Havoc






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