File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1717#include < cstring>
1818#include < cassert>
1919#include < iostream>
20+ #include < array>
2021#ifdef __linux__
2122#include < malloc.h>
2223#endif
@@ -193,16 +194,18 @@ namespace edm {
193194
194195 lseek (fd_, 0 , SEEK_SET);
195196
196- if ((cnt = read (fd_, buf_, sizeof (buf_) - 1 )) < 0 ) {
197+ std::array<char , 500 > buf;
198+
199+ if ((cnt = read (fd_, buf.data (), buf.size () - 1 )) < 0 ) {
197200 perror (" Read of Proc file failed:" );
198201 return ProcInfo ();
199202 }
200203
201204 if (cnt > 0 ) {
202- buf_ [cnt] = ' \0 ' ;
205+ buf [cnt] = ' \0 ' ;
203206
204207 try {
205- Fetcher fetcher (buf_ );
208+ Fetcher fetcher (buf. data () );
206209 fetcher >> pinfo.pid >> pinfo.comm >> pinfo.state >> pinfo.ppid >> pinfo.pgrp >> pinfo.session >> pinfo.tty >>
207210 pinfo.tpgid >> pinfo.flags >> pinfo.minflt >> pinfo.cminflt >> pinfo.majflt >> pinfo.cmajflt >>
208211 pinfo.utime >> pinfo.stime >> pinfo.cutime >> pinfo.cstime >> pinfo.priority >> pinfo.nice >>
Original file line number Diff line number Diff line change @@ -50,7 +50,6 @@ namespace edm {
5050 private:
5151 double pg_size_;
5252 int fd_;
53- mutable char buf_[500 ];
5453 };
5554 } // namespace service
5655} // namespace edm
You can’t perform that action at this time.
0 commit comments