[libgtop] Use a dynamically allocated buffer to read /proc/cpuinfo to handle computers with a lot of CPUs.
- From: Benoît Dejean <bdejean src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgtop] Use a dynamically allocated buffer to read /proc/cpuinfo to handle computers with a lot of CPUs.
- Date: Sat, 28 Jan 2017 08:52:42 +0000 (UTC)
commit b0ab056e99d83246475ef097dd27c04fafd49d70
Author: Benoît Dejean <bdejean gmail com>
Date: Sat Jan 21 09:49:22 2017 +0100
Use a dynamically allocated buffer to read /proc/cpuinfo to handle computers
with a lot of CPUs.
https://bugzilla.gnome.org/show_bug.cgi?id=323354
sysdeps/linux/sysinfo.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/sysdeps/linux/sysinfo.c b/sysdeps/linux/sysinfo.c
index bd80b0d..99d8fcc 100644
--- a/sysdeps/linux/sysinfo.c
+++ b/sysdeps/linux/sysinfo.c
@@ -36,16 +36,20 @@ static glibtop_sysinfo sysinfo = { .flags = 0 };
static void
init_sysinfo (glibtop *server)
{
- char buffer [65536];
+ char* buffer;
gchar ** processors;
if(G_LIKELY(sysinfo.flags)) return;
- file_to_buffer(server, buffer, sizeof buffer, FILENAME);
+ if (!g_file_get_contents(FILENAME, &buffer, NULL, NULL)) {
+ glibtop_error_io_r(server, "g_file_get_contents(%s)", FILENAME);
+ }
/* cpuinfo records are seperated by a blank line */
processors = g_strsplit(buffer, "\n\n", 0);
+ g_free(buffer);
+
for(sysinfo.ncpu = 0;
sysinfo.ncpu < GLIBTOP_NCPU && processors[sysinfo.ncpu] && *processors[sysinfo.ncpu];
sysinfo.ncpu++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]