]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Compactify unload_symbols().
authorNicholas Nethercote <njn@valgrind.org>
Sun, 14 Aug 2005 04:29:12 +0000 (04:29 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 14 Aug 2005 04:29:12 +0000 (04:29 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4403

coregrind/m_debuginfo/symtab.c

index 0d1beda566c0ec96d4ee70f1c23a0ae29e4580a4..6024dbb6c3aa1af235b651e566c5114568be5802 100644 (file)
@@ -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)