+ int n, i;
+ struct psensor **result, **cur, *s;
+
+ if (!sensors)
+ return NULL;
+
+ n = psensor_list_size(sensors);
+ result = malloc((n+1) * sizeof(struct psensor *));
+
+ for (cur = sensors, i = 0; *cur; cur++) {
+ s = *cur;
+
+ if (config_is_sensor_graph_enabled(s->id))
+ result[i++] = s;
+ }
+
+ result[i] = NULL;
+
+ return result;
+}
+
+/* Return the end time of the graph i.e. the more recent measure. If
+ * no measure are available, return 0.
+ * If Bezier curves are used return the measure n-3 to avoid to
+ * display a part of the curve outside the graph area.
+ */
+static time_t get_graph_end_time_s(struct psensor **sensors)
+{
+ time_t ret, t;
+ struct psensor *s;
+ struct measure *measures;
+ int i, n;
+
+ ret = 0;
+ while (*sensors) {
+ s = *sensors;
+ measures = s->measures;
+
+ if (is_smooth_curves_enabled)
+ n = 2;
+ else
+ n = 0;
+
+ for (i = s->values_max_length - 1; i >= 0; i--) {
+ if (measures[i].value != UNKNOWN_DBL_VALUE) {
+ if (!n) {
+ t = measures[i].time.tv_sec;
+
+ if (t > ret) {
+ ret = t;
+ break;
+ }
+ } else {
+ n--;
+ }
+ }
+ i--;
+ }