From: Guy Harris <[email-masked]>

Package: gtk+
Version: 1.2.4

OS: Solaris 2.5.1
X: X11R6 client libraries that come with Solaris 2.5.1, Exceed X11R6
   server running atop Windows NT

but it probably has the same problem with all versions of UNIX and X.

Bug:

If you call a routine to get or set a property of a row in a CList, it
finds the data for that row with a call to "g_list_nth()";
"g_list_nth()" is linear in the row number, so if you're constructing a
CList by adding a new entry and then setting properties of that entry,
that's quadratic in the ultimate size of the list.

However, a CList keeps around a pointer to the last element of the list
(so that appending an element to the end of the list isn't linear in the
size of the list), so if the reference is to the last row in the CList,
the data can be gotten without scanning the entire list.

This was discovered when Ethereal:

	http://ethereal.zing.org/

was changed to support coloring lines in the CList that shows one-line
summaries of all packets in the capture - as the row for a new packet
was added to the CList, the color would be set.

Fix:

Add a macro "ROW_ELEMENT()", which takes as arguments a pointer to a
CList and a row number, and that returns the data for that row; if the
row number is equal to the number of rows in the CList - 1, it uses the
end of list pointer, otherwise it uses "g_list_nth()".  Replace the
calls to "g_list_nth()" with that macro.

(I'm not wedded to the name of the macro; if it's a stupid name, feel
free to change it.)