I'm trying to call the following function which should fill an array with sensors' data and return the number of detected sensors:
uint8_t ds18b20_read_all(uint8_t pin, ds_sensor_t *result)
How am I supposed to call it without knowing the number of sensors? I thought about:
ds_sensor_t *result = (ds_sensor_t *) malloc(NUM_OF_SENSORS * sizeof(ds_sensor_t));
uint8_t count = ds18b20_read_all(pin, result);
But again I don't know NUM_OF_SENSORS. Should I just choose a large enough number?
EDIT: The source code of the function: https://github.com/SuperHouse/esp-open-rtos/blob/master/extras/ds18b20/ds18b20.c
reallocfunction every time you read data of new sensor. en.cppreference.com/w/c/memory/realloc It means that you can addyour sensors one by one toresult