Browse Source

Match new with delete for completeness.

Douglas William Thrift 14 years ago
parent
commit
86b5f3c2d8
1 changed files with 28 additions and 23 deletions
  1. 28 23
      dtpstree.cpp

+ 28 - 23
dtpstree.cpp

@@ -837,36 +837,41 @@ int main(int argc, char *argv[])
 				proc->printByName(tree);
 			}
 		}
-
-		return 0;
 	}
+	else
+	{
+		NameMap names;
 
-	NameMap names;
+		_foreach (PidMap, pid, pids)
+		{
+			Proc *proc(pid->second);
 
-	_foreach (PidMap, pid, pids)
-	{
-		Proc *proc(pid->second);
+			if (proc->root(uid))
+				switch (sort)
+				{
+				case PidSort:
+					proc->printByPid(tree);
 
-		if (proc->root(uid))
-			switch (sort)
-			{
-			case PidSort:
-				proc->printByPid(tree);
+					break;
+				case NameSort:
+					names.insert(NameMap::value_type(proc->name(), proc));
+				}
+		}
 
-				break;
-			case NameSort:
-				names.insert(NameMap::value_type(proc->name(), proc));
-			}
+		switch (sort)
+		{
+		case NameSort:
+			_foreach (NameMap, name, names)
+				name->second->printByName(tree);
+		default:
+			break;
+		}
 	}
 
-	switch (sort)
-	{
-	case NameSort:
-		_foreach (NameMap, name, names)
-			name->second->printByName(tree);
-	default:
-		return 0;
-	}
+	_foreach (PidMap, pid, pids)
+		delete pid->second;
+
+	return 0;
 }
 
 // display a tree of processes