summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2014-01-29 14:39:34 +0000
committerkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2014-01-29 14:39:34 +0000
commit4d3c6bc5cd31eaa6fbf5e36e8f62bc32ef35e1d9 (patch)
treedc1d74431b05d195974ecafefd5b7e9ab1dbf95a
parent6d3d0b331b842a3ba6141e28c81162ce41bbf30c (diff)
downloadlm-sensors-4d3c6bc5cd31eaa6fbf5e36e8f62bc32ef35e1d9.tar.gz
libsensors: Adjust memory pre-allocation steps
Make memory pre-allocation steps depend on the sensor type. Things like voltages, temperatures or fans are typically plenty, however vid and chassis intrusion are typically only a few, and there can only be one beep_enable by design. This saves a small amount of temporary memory for cheap. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6222 7894878c-1315-0410-8ee3-d5d059ff63e0
-rw-r--r--lib/sysfs.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c
index 6789127e..89ad4001 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -480,9 +480,11 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
/* (Re-)allocate memory if needed */
if (all_types[ftype].count < nr + 1) {
int old_count = all_types[ftype].count;
+ int step = ftype < SENSORS_FEATURE_VID ? 8 :
+ ftype < SENSORS_FEATURE_BEEP_ENABLE ? 2 : 1;
while (all_types[ftype].count < nr + 1)
- all_types[ftype].count += 8;
+ all_types[ftype].count += step;
all_types[ftype].sf = realloc(all_types[ftype].sf,
all_types[ftype].count *