Fix splay tree KEY leak detected in GDB test gdb.base/macscp.exp
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 12 Feb 2019 13:02:48 +0000 (13:02 +0000)
committerTom Tromey <tromey@adacore.com>
Tue, 12 Feb 2019 13:06:19 +0000 (06:06 -0700)
commite20773049fde7b9a123fda4485259fc06249b22f
treec5c01da0056ac3e64cabcdd96b44744e791c4278
parent04d7fa2132c05b962d85e2047646e15b8a490f4e
Fix splay tree KEY leak detected in GDB test gdb.base/macscp.exp

When a node is removed from a splay tree, the splay tree was
not using the function splay_tree_delete_key_fn to release the key.
This was causing a leak, fixed by Tom Tromey.

This patch fixes another key leak, that happens when a key equal to
a key already present is inserted.  In such a case, we have to release
the old KEY.
Note that this is based on the assumption that the caller always
allocates a new KEY when doing an insert.

Also, clarify the documentation about when the release functions are
called.

2019-02-11  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* splay-tree.h (splay_tree_delete_key_fn): Update comment.
(splay_tree_delete_value_fn): Likewise.

libiberty/ChangeLog
2019-02-11  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* splay-tree.c (splay_tree_insert): Also release old KEY in case
of insertion of a key equal to an already present key.
(splay_tree_new_typed_alloc): Update comment.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268793 138bc75d-0d04-0410-961f-82ee72b054a4
include/ChangeLog
include/splay-tree.h
libiberty/ChangeLog
libiberty/splay-tree.c
This page took 0.024082 seconds and 4 git commands to generate.