Commit Graph

26 Commits

Author SHA1 Message Date
tromey e20773049f 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
2019-02-12 06:06:19 -07:00
Tom Tromey d7167c671d Fix leak in splay-tree
Philippe Waroquiers noticed a memory leak in gdb, which he tracked
down to a bug in splay-tree.  splay_tree_remove does not call the
`delete_key' function when it removes the old node; but it should.

I looked at every splay tree in GCC and there is only one that passes
a non-NULL delete function -- the one in lto.c.  That file does not
call splay_tree_remove.  So, I think this is safe to check in.

I re-ran the LTO tests to double check.

libiberty/
	* splay-tree.c (splay_tree_remove): Delete the key if necessary.
2019-01-21 09:05:01 -07:00
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
edlinger 22467434fd include: 2018-05-28 Bernd Edlinger <bernd.edlinger@hotmail.de>
include:
        * splay-tree.h (splay_tree_compare_strings,
        splay_tree_delete_pointers): Declare new utility functions.

libiberty:
2018-05-28  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * splay-tree.c (splay_tree_compare_strings,
        splay_tree_delete_pointers): New utility functions.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@260850 138bc75d-0d04-0410-961f-82ee72b054a4
2018-05-31 10:17:13 +01:00
Nick Clifton 2a8ae7146c Update the libiberty sources with the latest patches found in the master sources.
2017-01-02  Richard Biener  <rguenther@suse.de>

	PR lto/83452
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_section):
	Do not use UNDEF locals for removed symbols but instead just
	define them in the first prevailing section and with no name.
	Use the same gnu_lto_v1 name for all removed globals we promote to
	WEAK UNDEFs so hpux can use a stub to provide this symbol.  Clear
	sh_info and sh_link in removed sections.

2017-10-30  Richard Biener  <rguenther@suse.de>

	PR lto/82757
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Strip two leading _s from the __gnu_lto_* symbols.

2017-10-24  Alan Modra  <amodra@gmail.com>

	PR lto/82687
	PR lto/82575
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Only make __gnu_lto symbols hidden.

2017-10-20  Alan Modra  <amodra@gmail.com>

	PR lto/82575
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	Make discarded non-local symbols weak and hidden.

2017-10-18  Jakub Jelinek  <jakub@redhat.com>

	PR lto/82598
	* simple-object.c (handle_lto_debug_sections): Copy over also
	.note.GNU-stack section with unchanged name.
	* simple-object-elf.c (SHF_EXECINSTR): Define.
	(simple_object_elf_copy_lto_debug_section): Drop SHF_EXECINSTR bit
	on .note.GNU-stack section.

2017-09-25  Nathan Sidwell  <nathan@acm.org>

	PR demangler/82195
	* cp-demangle.c (d_encoding): Strip return type when name is a
	LOCAL_NAME.
	(d_local_name): Strip return type of enclosing TYPED_NAME.
	* testsuite/demangle-expected: Add and adjust tests.

2017-09-21  Nathan Sidwell  <nathan@acm.org>

	PR demangler/82195
	* cp-demangle.c (d_name): Revert addition of 'toplevel' parm.
	(has_return_type): Recurse for DEMANGLE_COMPONENT_LOCAL_NAME.
	(d_encoding): Revert d_name change.  Use is_fnqual_component_type
	to strip modifiers that do not belong.
	(d_special_name, d_class_enum_type): Revert d_name call change.
	(d_expresion_1): Commonize DEMANGLE_COMPONENT_UNARY building.
	(d_local_name): Revert parsing of a function type.
	(d_print_comp_inner): An inner LOCAL_NAME might contain a
	TEMPLATE.
	* testsuite/demangle-expected: Add & adjust tests
2018-01-10 13:57:48 +00:00
Alan Modra e495212d22 Sync libiberty from gcc
Picks up copyright year update and other recent fixes.
2017-01-05 00:03:07 +10:30
Ralf Wildenhues d4d868a280 libiberty: documentation markup and order fixes.
libiberty/:
	* splay-tree.c: Escape wrapping newlines in texinfo markup
	with '@', to fix function declaration output rendering.
	* gather-docs: Relax and improve macro name matching to actually
	match all current names and to allow input line wrapping.
	* bsearch.c, concat.c, crc32.c, fnmatch.txh, fopen_unlocked.c,
	hashtab.c, insque.c, make-relative-prefix.c, memchr.c, memcmp.c,
	memcpy.c, memmem.c, memmove.c, mempcpy.c, memset.c,
	pexecute.txh, random.c, setenv.c, setproctitle.c,
	simple-object.txh, snprintf.c, stpncpy.c, strncmp.c, strtod.c,
	strtol.c, vasprintf.c, vprintf.c, vsnprintf.c, xmemdup.c:
	Wrap long texinfo input lines.
	* functions.texi: Regenerate.
2011-02-03 07:23:59 +00:00
DJ Delorie 98f0b5d4e5 merge from gcc 2010-12-08 16:24:43 +00:00
DJ Delorie 219a461e6c merge from gcc 2010-06-10 18:30:24 +00:00
DJ Delorie 145f4ab500 merge from gcc 2008-01-19 01:18:42 +00:00
DJ Delorie 718c0ded1f merge from gcc 2005-11-07 16:36:16 +00:00
Nick Clifton 979c05d324 Update the address and phone number of the FSF organization. 2005-05-10 15:33:34 +00:00
DJ Delorie 1e45deed6a merge from gcc 2005-03-28 05:07:08 +00:00
DJ Delorie 9923bc337e merge from gcc 2004-12-07 20:02:09 +00:00
DJ Delorie 0f3538e70e merge from gcc 2003-05-07 19:15:59 +00:00
DJ Delorie 585cc78f65 merge from gcc 2002-09-20 13:45:20 +00:00
DJ Delorie a54ba43fe9 merge from gcc 2002-09-12 01:11:29 +00:00
Jim Blandy 3ddbd84c49 * splay-tree.c (splay_tree_xmalloc_allocate,
splay_tree_xmalloc_deallocate): Use K&R-style definitions, not
prototyped definitions.  Mark `data' arguments as unused.
2002-03-07 00:16:50 +00:00
Jim Blandy 2bbcdae974 include:
Allow the user to specify functions for allocating memory for
splay tree roots and nodes.
* splay-tree.h (splay_tree_allocate_fn, splay_tree_deallocate_fn):
New types.
(splay_tree): New fields: `allocate', `deallocate', and
`allocate_data'.
(splay_tree_new_with_allocator): New function declaration.

libiberty:

* splay-tree.c (splay_tree_xmalloc_allocate,
splay_tree_xmalloc_deallocate): New functions.
(splay_tree_new): Call splay_tree_new_with_allocator, passing the
above functions and a dummy data pointer.
(splay_tree_new_with_allocator): New function.
(splay_tree_delete_helper, splay_tree_delete, splay_tree_insert,
splay_tree_remove): Use the splay tree's allocation and
deallocation functions.
2002-02-21 22:19:14 +00:00
DJ Delorie e00bc6a7ba merge from gcc 2001-05-07 16:21:15 +00:00
DJ Delorie 74bcd5294f merge from gcc repository 2000-10-12 02:16:48 +00:00
DJ Delorie 60c6451942 * splay-tree.c: #include <stdio.h>. 2000-09-15 15:16:11 +00:00
Richard Henderson afe36a788b * splay-tree.c (splay_tree_remove): New. 2000-04-06 00:16:01 +00:00
Ian Lance Taylor 0c0a36a403 merge with libiberty from egcs 2000-02-22 2000-02-22 16:14:35 +00:00
Ian Lance Taylor af32ff6969 * splay-tree.c (splay_tree_insert): Add initialization to avoid
warning.
1999-07-11 19:13:51 +00:00
Richard Henderson 252b5132c7 19990502 sourceware import 1999-05-03 07:29:11 +00:00