Hello Arno,
Can one remove a node in onlist?

Regards,

SubZ
On Sun, Dec 4, 2011 at 13:16, Arno Garrels <arno.garr...@gmx.de> wrote:

> Fastream Technologies wrote:
> > Do you mean the tree self-destructs nodes and I will be notified of
> > it to delete?
>
> You are notified before the class removes and frees a node, i.e method
> Remove() triggers event OnFreeData and afterwards frees the node. The class
> doesn't own Data but its nodes, so never call method Free of a node
> returned
> by a method.
> However if Data points to some previously allocated memory you are
> responsible to release it.
>
> > Or is it optional?
>
> Yes, more or less it is. If you, for instance, used Data to store
> just an Integer value it's not required to free any memory.
>
>
> Example:
>
> procedure TForm1.CacheFreeData(Sender: TObject; Data: Pointer; Len:
> Integer);
> begin
>    FreeMem(Data);
> end;
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
>    Node: TCacheNode;
>    MyData: Pointer;
> begin
>    FCache := TCacheTree.Create;
>    try
>        FCache.OnFreeData := CacheFreeData;
>        GetMem(MyData, 1024);
>        FCache.Insert('AKEY', MyData, 0, Now);
>        // either
>        Node := FCache.FindKey('AKEY');
>        if Node <> nil then
>            FCache.Remove(Node); // Node no longer valid
>        // or
>        FCache.RemoveKey('AKEY');
>    finally
>        FCache.Free;
>    end;
> end;
>
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to