1 /* $NetBSD: dwarf_dealloc.c,v 1.2 2014/03/09 16:58:03 christos Exp $ */
4 * Copyright (c) 2007 John Birrell (jb@freebsd.org)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include "_libdwarf.h"
31 __RCSID("$NetBSD: dwarf_dealloc.c,v 1.2 2014/03/09 16:58:03 christos Exp $");
32 ELFTC_VCSID("Id: dwarf_dealloc.c 2073 2011-10-27 03:30:47Z jkoshy ");
35 dwarf_dealloc(Dwarf_Debug dbg
, Dwarf_Ptr p
, Dwarf_Unsigned alloc_type
)
38 Dwarf_AttrDef ad
, tad
;
39 Dwarf_Attribute at
, tat
;
43 * This libdwarf implementation does not use the SGI/libdwarf
44 * style of memory allocation. In most cases it does not copy
45 * things to return to the client, so the client does not need
46 * to remember to free them. The remaining cases are handled
52 if (alloc_type
== DW_DLA_LIST
|| alloc_type
== DW_DLA_FRAME_BLOCK
||
53 alloc_type
== DW_DLA_LOC_BLOCK
|| alloc_type
== DW_DLA_LOCDESC
)
55 else if (alloc_type
== DW_DLA_ABBREV
) {
57 STAILQ_FOREACH_SAFE(ad
, &ab
->ab_attrdef
, ad_next
, tad
) {
58 STAILQ_REMOVE(&ab
->ab_attrdef
, ad
, _Dwarf_AttrDef
,
63 } else if (alloc_type
== DW_DLA_DIE
) {
65 STAILQ_FOREACH_SAFE(at
, &die
->die_attr
, at_next
, tat
) {
66 STAILQ_REMOVE(&die
->die_attr
, at
,
67 _Dwarf_Attribute
, at_next
);
68 if (at
->at_ld
!= NULL
)
72 if (die
->die_attrarray
)
73 free(die
->die_attrarray
);
79 dwarf_srclines_dealloc(Dwarf_Debug dbg
, Dwarf_Line
*linebuf
,
83 * In this libdwarf implementation, line information remains
84 * associated with the DIE for a compilation unit for the
85 * lifetime of the DIE. The client does not need to free
86 * the memory returned by `dwarf_srclines()`.
89 (void) dbg
; (void) linebuf
; (void) count
;
93 dwarf_ranges_dealloc(Dwarf_Debug dbg
, Dwarf_Ranges
*ranges
,
94 Dwarf_Signed range_count
)
97 * In this libdwarf implementation, ranges information is
98 * kept by a STAILQ inside Dwarf_Debug object. The client
99 * does not need to free the memory returned by
100 * `dwarf_get_ranges()` or `dwarf_get_ranges_a()`.
103 (void) dbg
; (void) ranges
; (void) range_count
;
107 dwarf_fde_cie_list_dealloc(Dwarf_Debug dbg
, Dwarf_Cie
*cie_list
,
108 Dwarf_Signed cie_count
, Dwarf_Fde
*fde_list
, Dwarf_Signed fde_count
)
111 * In this implementation, FDE and CIE information is managed
112 * as part of the Dwarf_Debug object. The client does not need
113 * to explicitly free these memory arenas.