From: | Rod Schnell |
Date: | 30 Aug 2000 at 05:03:30 |
Subject: | Re: Freeing list with Classact |
Hello Jack,
Well, I managed to duplicate your listbrowser problem tonight. ClassAct
uses an internal memory for most gadgets, including listbrowser. I have to
guess it's a global pool shared between all gadgets. However, there is a
simple solution. Just use a seperate pool for each listbrowser with huge
numbers of nodes. For example...
APTR pool1;
APTR pool2;
struct List lblist;
struct List lblist2;
if (pool1 = CreatePool(MEMF_CLEAR | MEMF_ANY | MEMF_PUBLIC, 8192,512))
{
pool2 = CreatePool(MEMF_CLEAR | MEMF_ANY | MEMF_PUBLIC, 8192,512);
}
if(pool2 == NULL)
{
if(pool1 != NULL)
DeletePool(pool1);
return(20);
}
NewList(&lblist);
NewList(&lblist2);
MakeLbNodes(&lblist, pool1);
MakeLbNodes(&lblist2, pool2);
BOOL MakeLbNodes(struct List *list, APTR pool)
{
struct Node *node;
LONG i = 0, last = 5000;
char buf[81];
if (!list)
return(FALSE);
sprintf(buf, "We'll repeat ourselves %ld times for testing purposes...",
last);
while(i < last)
{
if(node = AllocListBrowserNode(2,
LBNA_MemPool, pool, // This line does the trick
LBNA_Column, 0,
LBNCA_CopyInteger, TRUE,
LBNCA_Integer, &i,
LBNCA_Justification, LCJ_RIGHT,
LBNA_Column,1,
LBNCA_CopyText, TRUE,
LBNCA_Text, buf,
TAG_DONE))
{
AddTail(list, node);
}
else
{
FreeLbnList(list);
return(FALSE);
}
i++;
}
return(TRUE);
}
Nothing needs to change in your ListBrowser creation or node freeing
code, just create a pool and feed it's pointer to AllocListBrowserNode().
ListBrowser will handle the rest.
Regards, Rod