From 1262f710b548100e4522866341febba3d7cf535d Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Tue, 28 Jun 2011 23:09:00 -0400
Subject: [PATCH] CHOP-753: Report Linux memory stats 1/line, like other
 platforms. Previous code deliberately flowed the different lines from
 MEMINFO_FILE together on a single line, which seems pointless to me, since we
 want to be able to grep the viewer log to recognize individual stats. Also
 replace classic-C LLFILE* machinery used to read MEMINFO_FILE with
 std::ifstream and std::getline().

---
 indra/llcommon/llsys.cpp | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index ccd6f261b70..f0f98f5bf64 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -853,17 +853,14 @@ void LLMemoryInfo::stream(std::ostream& s) const
         s << pfx << "Total Physical KB:  " << phys << std::endl;
 
 #elif LL_LINUX
-	LLFILE* meminfo = LLFile::fopen(MEMINFO_FILE,"rb");
-	if(meminfo)
+	std::ifstream meminfo(MEMINFO_FILE);
+	if (meminfo.is_open())
 	{
-		char line[MAX_STRING];		/* Flawfinder: ignore */
-		memset(line, 0, sizeof(line));
-		while(fgets(line, sizeof(line), meminfo))
+		std::string line;
+		while (std::getline(meminfo, line))
 		{
-			line[strlen(line)-1] = ' ';		 /*Flawfinder: ignore*/
-			s << pfx << line;
+			s << pfx << line << '\n';
 		}
-		fclose(meminfo);
 	}
 	else
 	{
-- 
GitLab