It would be more optimized to read a section of the /proc/<pid>/maps file at a time and parse it; if the results were found, free the buffer and return; else, just read once again. This might be applicable to other files, such as /proc/<pid>/status, but since they're not so big, it might not be necessary for performance increase. Instead, it might be a good idea to read until the end of life and pass the read line to a function.
It would be more optimized to read a section of the
/proc/<pid>/maps
file at a time and parse it; if the results were found, free the buffer and return; else, just read once again. This might be applicable to other files, such as/proc/<pid>/status
, but since they're not so big, it might not be necessary for performance increase. Instead, it might be a good idea to read until the end of life and pass the read line to a function.