C (6/304)

From:Rod Schnell
Date:02 Aug 2000 at 09:48:01
Subject:Freeing list with Classact

Hello Jack

I printed your message on the PC at work and I'm replying from the amiga
at home, so no quoting here.

First off, I have to wonder just how many ListBrowserNodes are in your list
and how big the nodes are?

Secondly, I don't use FreeListBrowserNodes() myself, in fact it's not even in
the beta version of classact.library that I have. A much better way is to
detach
the list, walk it, free each node and then reattach the list after all the
nodes have been freed. This way there's only one refresh.

/* Function to free an Exec List of ListbrowserNodes
* The list must -NOT- be attached to a listbrowser!
*
* SetGadgetAttrs(listbrowser, window, NULL,
* LISTBROWSER_Labels, ~0,
* TAG_DONE);
* FreeLbnList(list);
* SetGadgetAttrs(listbrowser, window, NULL,
* LISTBROWSER_Labels, list,
* TAG_DONE);
*/

VOID FreeLbnList(struct List *list)
{
struct Node *node;

if (!list)
return;

while (node = RemTail(list))
FreeListBrowserNode(node);

NewList(list); // prep list for possible reuse
}

On my 040/25mhz this code frees a list of 10,000 two column nodes each
containing an integer column and a 55-60 char text column in roughly 3
seconds.

And btw, RemTail() as above will certainly cause problems if the list is
still attached to a listbrowser... If the list is attached, you'd have to use
LBM_REMNODE instead and it would be much slower.

Regards, Rod