From: Nicholas Nethercote Date: Sun, 14 Aug 2005 04:29:12 +0000 (+0000) Subject: Compactify unload_symbols(). X-Git-Tag: svn/VALGRIND_3_1_0~615 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=81903d273f6858df85a6744db03b89411f8b4cf6;p=thirdparty%2Fvalgrind.git Compactify unload_symbols(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4403 --- diff --git a/coregrind/m_debuginfo/symtab.c b/coregrind/m_debuginfo/symtab.c index 0d1beda566..6024dbb6c3 100644 --- a/coregrind/m_debuginfo/symtab.c +++ b/coregrind/m_debuginfo/symtab.c @@ -1703,36 +1703,28 @@ SegInfo *VG_(read_seg_symbols) ( Addr seg_addr, SizeT seg_len, */ static void unload_symbols ( Addr start, SizeT length ) { - SegInfo *prev, *curr; - - prev = NULL; - curr = segInfo_list; - while (True) { - if (curr == NULL) break; - if (start == curr->start) break; - prev = curr; - curr = curr->next; - } - if (curr == NULL) { - VGP_POPCC(VgpReadSyms); - return; - } - - if (VG_(clo_verbosity) > 1) - VG_(message)(Vg_DebugMsg, - "discard syms at %p-%p in %s due to munmap()", - start, start+length, curr->filename ? curr->filename : (Char *)"???"); - - vg_assert(prev == NULL || prev->next == curr); - - if (prev == NULL) { - segInfo_list = curr->next; - } else { - prev->next = curr->next; + SegInfo** prev_next_ptr = &segInfo_list; + SegInfo* curr = segInfo_list; + + while (curr) { + if (start == curr->start) { + // Found it; remove from list and free it. + if (VG_(clo_verbosity) > 1) + VG_(message)(Vg_DebugMsg, + "discard syms at %p-%p in %s due to munmap()", + start, start+length, + curr->filename ? curr->filename : (Char *)"???"); + vg_assert(*prev_next_ptr == curr); + *prev_next_ptr = curr->next; + freeSegInfo(curr); + return; + } + prev_next_ptr = &curr->next; + curr = curr->next; } - freeSegInfo(curr); - return; + // Not found. + VGP_POPCC(VgpReadSyms); } void VG_(seginfo_decref)(SegInfo *si, Addr start)