Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Jan 2008 20:44:15 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 132807 for review
Message-ID:  <200801082044.m08KiFAg012968@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=132807

Change 132807 by jb@jb_freebsd1 on 2008/01/08 20:44:11

	Free memory when finished.

Affected files ...

.. //depot/projects/dtrace/src/lib/libdwarf/dwarf_finish.c#2 edit

Differences ...

==== //depot/projects/dtrace/src/lib/libdwarf/dwarf_finish.c#2 (text+ko) ====

@@ -32,9 +32,17 @@
 int
 dwarf_finish(Dwarf_Debug *dbgp, Dwarf_Error *error)
 {
+	Dwarf_Abbrev ab;
+	Dwarf_Abbrev tab;
+	Dwarf_Attribute at;
+	Dwarf_Attribute tat;
+	Dwarf_AttrValue av;
+	Dwarf_AttrValue tav;
 	Dwarf_CU cu;
 	Dwarf_CU tcu;
 	Dwarf_Debug dbg;
+	Dwarf_Die die;
+	Dwarf_Die tdie;
 
 	if (error == NULL)
 		/* Can only return a generic error. */
@@ -50,6 +58,30 @@
 
 	/* Free entries in the compilation unit list. */
 	STAILQ_FOREACH_SAFE(cu, &dbg->dbg_cu, cu_next, tcu) {
+		/* Free entries in the die list */
+		STAILQ_FOREACH_SAFE(die, &cu->cu_die, die_next, tdie) {
+			/* Free entries in the attribute value list */
+			STAILQ_FOREACH_SAFE(av, &die->die_attrval, av_next, tav) {
+				STAILQ_REMOVE(&die->die_attrval, av, _Dwarf_AttrValue, av_next);
+				free(av);
+			}
+
+			STAILQ_REMOVE(&cu->cu_die, die, _Dwarf_Die, die_next);
+			free(die);
+		}
+
+		/* Free entries in the abbrev list */
+		STAILQ_FOREACH_SAFE(ab, &cu->cu_abbrev, a_next, tab) {
+			/* Free entries in the attribute list */
+			STAILQ_FOREACH_SAFE(at, &ab->a_attrib, at_next, tat) {
+				STAILQ_REMOVE(&ab->a_attrib, at, _Dwarf_Attribute, at_next);
+				free(at);
+			}
+
+			STAILQ_REMOVE(&cu->cu_abbrev, ab, _Dwarf_Abbrev, a_next);
+			free(ab);
+		}
+
 		STAILQ_REMOVE(&dbg->dbg_cu, cu, _Dwarf_CU, cu_next);
 		free(cu);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801082044.m08KiFAg012968>