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.
This commit is contained in:
Jean Delvare committed 2014-01-29 14:39:34 +00:00
1 parent 0159202226
commit b9361dc088
1 file changed
+3 -1
+3 -1
View File
@@ -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 *