The entries in sensor list always start with either server address or
mount point, which is not counted as a sensor. If we want to count the
actual number of sensors, we obviously need to add one more to the
last index number, otherwise we get one too small number for sensors
and allocate too little of memory for the parser state.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
{
int i;
- /* Count how many sensor entries we need */
+ /*
+ * Count how many sensor entries we need. First entry belongs
+ * to server address or mount point and last one is NULL. So
+ * the index final is the count of actual valid sensor
+ * entries.
+ */
for (i = 0; datastr[i]; i++)
;
- /* The first entry belongs to server address or mount point */
- i--;
-
return calloc(sizeof(struct owparser_state), i);
}