Mailing List Archive

[Bug 474] ACL condition to unset a variable
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=474





------- Comment #1 from anomie@users.sourceforge.net 2007-02-17 01:01 -------
Created an attachment (id=72)
--> (http://www.exim.org/bugzilla/attachment.cgi?id=72&action=view)
The mentioned patch.

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 474] ACL condition to unset a variable [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=474





------- Comment #2 from anomie@users.sourceforge.net 2007-02-17 01:02 -------
Created an attachment (id=73)
--> (http://www.exim.org/bugzilla/attachment.cgi?id=73&action=view)
A speculative patch in case someone writes tree_removenode

If someone decides to write a "tree_removenode(tree_node **root, tree_node
*node)" function, here is a patch that would use it. Obviously, i can't have
tested this, but it is only slightly different from the previous patch.

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 474] ACL condition to unset a variable [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=474





------- Comment #3 from ph10@hermes.cam.ac.uk 2007-02-21 12:05 -------
(In reply to comment #2)
> Created an attachment (id=73)
--> (http://www.exim.org/bugzilla/attachment.cgi?id=73&action=view) [details]
> A speculative patch in case someone writes tree_removenode

The tree is a binary balanced tree. I do not know of an algorithm for removing
nodes and keeping the tree still balanced. These trees are intended for
additions, but not subtractions. Therefore, I don't think anybody will ever
write tree_removenode.

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 474] ACL condition to unset a variable [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=474





------- Comment #4 from anomie@users.sourceforge.net 2007-02-21 17:38 -------
On Wed, Feb 21, 2007 at 12:05:44PM +0000, ph10@hermes.cam.ac.uk wrote:
>
> The tree is a binary balanced tree. I do not know of an algorithm for removing
> nodes and keeping the tree still balanced. These trees are intended for
> additions, but not subtractions. Therefore, I don't think anybody will ever
> write tree_removenode.

Some quick searching turns up this algorithm for AVL balanced binary trees:

If the node to remove is a leaf, you can just remove it. Then
rebalance.

If the node to remove has only one child, you can remove the node
and put the child in its place. The tree has always become shorter,
so rebalance.

Otherwise, pick either the largest node from the left subtree or the
smallest node from the right subtree of the to-be-removed node,
which will always fall into one of the above two cases. Remove this
moved-node from the tree as above and replace the to-be-removed node
with it, and rebalance ('starting' from where the moved-node used to
be, not from where the to-be-removed node was).
D C E
/ \ / \ / \
B F => B F or B F
/ \ / \ / / \ / \ \
A C E G A E G A C G

Rebalancing seems to be a little more complicated than in the insertion
case, since the tree may need to be rebalanced at more than one point.
Let me explain my reasoning (mainly for my own use if I get time to
implement this).

The 'balance factor' of a node is the difference between the height of
the left subtree and the height of the right subtree (R-L, usually); in
a balanced tree this is either -1, 0, or +1. An insertion or deletion
changes the balance factor of the parent node by 1 (± depending on which
operation and which side of the parent it is on), and if the new factor
is -2 or +2 we perform a rotation which returns the factor to 0. So far
so good.

In insertion, changing the balance factor on a node from ±1 to 0
(either directly changing from ±1 to 0, or by changing to ±2 then
rotating) means the height of the subtree rooted at this node has not
changed and therefore the node's parent's balance factor has not
changed. Otherwise, we need to adjust the balance on the node's parent
(-1 if this is the left node and +1 if this is the right) and iterate
this paragraph. Note that only 1 rotation is ever needed since any
rotation moves to 0, and this rotation can only ever be at the most
recent parent that is ±1. Exim takes advantage of this.

In deletion, changing the balance factor on a node from ±1 to 0
means the height of the subtree rooted at this node HAS changed. We can
limit the changes to the subtree rooted at the most recent parent that
is 0, but there is a possible rotation at every parent in between. At
least we can determine if rotation is needed for any parent just by
considering that parent's balance and the side that contained the
deleted node.

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email
[Bug 474] ACL condition to unset a variable [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=474





------- Comment #5 from kjetilho@ifi.uio.no 2007-02-21 18:31 -------
I'm sorry, but I don't see why this is worthwhile. you can set the variable to
"" to save memory, so the only thing gained by unsetting variables is that they
don't have to be listed in the queue file. so we save perhaps 32 bytes of disk
space for each such variable.

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 474] ACL condition to unset a variable [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=474





------- Comment #6 from bugzilla.exim.simon@arlott.org 2007-02-21 20:54 -------
Surely this is the point of unsetting variables?

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
Re: [Bug 474] ACL condition to unset a variable [ In reply to ]
On Wed, 21 Feb 2007, kjetilho@ifi.uio.no wrote:

> ------- Comment #5 from kjetilho@ifi.uio.no 2007-02-21 18:31 -------
> I'm sorry, but I don't see why this is worthwhile. you can set the variable to
> "" to save memory, so the only thing gained by unsetting variables is that they
> don't have to be listed in the queue file. so we save perhaps 32 bytes of disk
> space for each such variable.

On Wed, 21 Feb 2007, bugzilla.exim.simon@arlott.org wrote:

> ------- Comment #6 from bugzilla.exim.simon@arlott.org 2007-02-21 20:54 -------
> Surely this is the point of unsetting variables?

(1) Setting a previously set variable to "" is unlikely to save memory,
because the old value's memory probably won't be re-used.

(2) Unless you use a zillion variables, saving 32 bytes of queue file
for each variable is hardly going to affect anything.

(3) The original patch that marks the variable "unset", without fiddling
with the tree, would in any case achieve that.

(4) I cannot see the point of implementing a complicated and tricky
algorithm to actually remove nodes from the tree. I can't see any
benefit at all, and in any case if there were any benefit it would be
for a small number of users.

--
Philip Hazel University of Cambridge Computing Service
Get the Exim 4 book: http://www.uit.co.uk/exim-book

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 474] ACL condition to unset a variable [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=474





------- Comment #7 from ph10@hermes.cam.ac.uk 2007-02-22 09:55 -------
On Wed, 21 Feb 2007, kjetilho@ifi.uio.no wrote:

> ------- Comment #5 from kjetilho@ifi.uio.no 2007-02-21 18:31 -------
> I'm sorry, but I don't see why this is worthwhile. you can set the variable to
> "" to save memory, so the only thing gained by unsetting variables is that they
> don't have to be listed in the queue file. so we save perhaps 32 bytes of disk
> space for each such variable.

On Wed, 21 Feb 2007, bugzilla.exim.simon@arlott.org wrote:

> ------- Comment #6 from bugzilla.exim.simon@arlott.org 2007-02-21 20:54 -------
> Surely this is the point of unsetting variables?

(1) Setting a previously set variable to "" is unlikely to save memory,
because the old value's memory probably won't be re-used.

(2) Unless you use a zillion variables, saving 32 bytes of queue file
for each variable is hardly going to affect anything.

(3) The original patch that marks the variable "unset", without fiddling
with the tree, would in any case achieve that.

(4) I cannot see the point of implementing a complicated and tricky
algorithm to actually remove nodes from the tree. I can't see any
benefit at all, and in any case if there were any benefit it would be
for a small number of users.

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
Re: [Bug 474] ACL condition to unset a variable [ In reply to ]
On Wed, 21 Feb 2007, anomie@users.sourceforge.net wrote:

> ------- Comment #4 from anomie@users.sourceforge.net 2007-02-21 17:38 -------
> On Wed, Feb 21, 2007 at 12:05:44PM +0000, ph10@hermes.cam.ac.uk wrote:
> >
> > The tree is a binary balanced tree. I do not know of an algorithm for removing
> > nodes and keeping the tree still balanced. These trees are intended for
> > additions, but not subtractions. Therefore, I don't think anybody will ever
> > write tree_removenode.
>
> Some quick searching turns up this algorithm for AVL balanced binary trees:

I suspect it isn't an AVL balanced tree (though not being sure what AVL
is, I can't be certain). The algorithm I use to build the tree comes
from Knuth, and I originally coded it many years ago.

I see absolutely no benefit from spending resources removing nodes from
the tree.

--
Philip Hazel University of Cambridge Computing Service
Get the Exim 4 book: http://www.uit.co.uk/exim-book

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 474] ACL condition to unset a variable [ In reply to ]
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

http://www.exim.org/bugzilla/show_bug.cgi?id=474





------- Comment #8 from ph10@hermes.cam.ac.uk 2007-02-22 09:58 -------
On Wed, 21 Feb 2007, anomie@users.sourceforge.net wrote:

> ------- Comment #4 from anomie@users.sourceforge.net 2007-02-21 17:38 -------
> On Wed, Feb 21, 2007 at 12:05:44PM +0000, ph10@hermes.cam.ac.uk wrote:
> >
> > The tree is a binary balanced tree. I do not know of an algorithm for removing
> > nodes and keeping the tree still balanced. These trees are intended for
> > additions, but not subtractions. Therefore, I don't think anybody will ever
> > write tree_removenode.
>
> Some quick searching turns up this algorithm for AVL balanced binary trees:

I suspect it isn't an AVL balanced tree (though not being sure what AVL
is, I can't be certain). The algorithm I use to build the tree comes
from Knuth, and I originally coded it many years ago.

I see absolutely no benefit from spending resources removing nodes from
the tree.

--
Configure bugmail: http://www.exim.org/bugzilla/userprefs.cgi?tab=email

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##