{
struct data_source *ds;
int ds_n = data_sources_get_n();
- int header_lines = 2;
- gchar **header_items = g_new(gchar *, (ds_n + 1) * header_lines);
+ gchar **header_items[2];
gchar *str = NULL;
+ for (size_t i = 0; i < sizeof(header_items)/sizeof(header_items[0]); i++)
+ header_items[i] = g_new(gchar *, ds_n + 1);
+
for (int i = 0; i < ds_n; i++) {
ds = &(process->data_sources[i]);
- header_items[(ds_n + 1) * 0 + i] = g_strdup_printf("%s%-20s", i > 0 ? " | " : "", ds->param_name);
- header_items[(ds_n + 1) * 1 + i] = g_strdup_printf("%s%-10s%-10s", i > 0 ? " | " : "", "peak ---- ", "avg ------");
+ header_items[0][i] = g_strdup_printf("%s%-20s", i > 0 ? " | " : "", ds->param_name);
+ header_items[1][i] = g_strdup_printf("%s%-10s%-10s", i > 0 ? " | " : "", "peak ---- ", "avg ------");
}
/* Print the header line by line */
- for (int i = 0; i < header_lines; i++) {
- header_items[(ds_n + 1) * i + ds_n] = NULL;
- str = g_strjoinv(NULL, &header_items[(ds_n + 1) * i]);
+ for (size_t i = 0; i < sizeof(header_items)/sizeof(header_items[0]); i++) {
+ header_items[i][ds_n] = NULL;
+ str = g_strjoinv(NULL, header_items[i]);
_I_PROC(process, "%s", str);
g_free(str);
+ g_strfreev(header_items[i]);
}
-
- g_strfreev(header_items);
}
void process_print_current_state(struct proc_info *process)
struct smpl_container *sc;
struct sample_s *last_sample;
int ds_n = data_sources_get_n();
- gchar **state_items = g_new(gchar *, ds_n);
+ gchar **state_items = g_new(gchar *, ds_n + 1);
gchar *avg_item;
gchar *state_msg = NULL;
static unsigned long long last_msg_count = 0;