]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf: Replace list of elf_getdata_rawchunk results with a tree
authorMark Wielaard <mark@klomp.org>
Wed, 21 Jun 2023 16:05:12 +0000 (18:05 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 27 Jun 2023 14:05:28 +0000 (16:05 +0200)
commit35e059b654224b1a01d05877b13582c74c692388
tree32db753a84ce197315799cb6857b310da51c5e49
parent485b87a2e53045d2284a6649d529ab3aaa22e127
libelf: Replace list of elf_getdata_rawchunk results with a tree

elf_getdata_rawchunks did a linear search to see if a chunk was
already fetched. Replace this list with a binary search tree to make
lookup faster when a lot of Elf_Data_Chunk were created.

       * libelf/libelfP.h (Elf_Data_Chunk): Remove next field.
       (struct Elf): Change the rawchunks type from Elf_Data_Chunk *
       to void *.
       * elf_getdata_rawchunk.c (chunk_compare): New static function.
       (elf_getdata_rawchunk): Use tsearch instead of a manual linked
       list.
       * elf_end.c (free_chunk): New static function.
       (elf_end): Call tdestroy instead of walking linked list.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libelf/elf_end.c
libelf/elf_getdata_rawchunk.c
libelf/libelfP.h