[libbacktrace] Simplify memory management in build_address_map
authorTom de Vries <tdevries@suse.de>
Fri, 28 Dec 2018 03:43:41 +0000 (03:43 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Fri, 28 Dec 2018 03:43:41 +0000 (03:43 +0000)
commitd9aa0961ea1b37aa2159761b147e9668422925ba
treed8f22fb7f9f03de37f2adc91fb45badba377d6b3
parent40b8d3b2536246b7449b6c7ce7a972537e5f11e1
[libbacktrace] Simplify memory management in build_address_map

In the main loop in build_address_map, we first read the abbrevs into a local
variable abbrevs, and then allocate the corresponding unit, after which we assign
the abbrevs to the unit.  This results in dedicated free-upon-failure
handling for the variable, and extra code to make sure that free-upon-failure
doesn't trigger once the unit has taken ownership of the abbrevs.

Simplify this by reversing the order of abbrev reading and unit allocation,
and eliminating the abbrevs local variable.

Bootstrapped and reg-tested on x86_64.

2018-12-28  Tom de Vries  <tdevries@suse.de>

* dwarf.c (build_address_map): Simplify by removing local variable
abbrevs.

From-SVN: r267444
libbacktrace/ChangeLog
libbacktrace/dwarf.c