unsigned int i;
LttTracefile *tf;
- if (group->len > 0)
- destroy_marker_data(g_array_index (group, LttTracefile, 0).mdata);
for(i=0; i<group->len; i++) {
tf = &g_array_index (group, LttTracefile, i);
- if(tf->cpu_online)
+ if(tf->cpu_online) {
+ destroy_marker_data(tf->mdata);
ltt_tracefile_close(tf);
+ }
}
g_array_free(group, TRUE);
}
DIR *dir = opendir(root_path);
struct dirent *entry;
struct stat stat_buf;
- int ret, i;
- struct marker_data *mdata;
+ int ret;
gchar path[PATH_MAX];
int path_len;
gchar rel_path[PATH_MAX];
gchar *rel_path_ptr;
LttTracefile tmp_tf;
+ struct marker_data **mdata;
if(dir == NULL) {
perror(root_path);
g_debug("Tracefile name is %s and number is %u",
g_quark_to_string(name), num);
- mdata = NULL;
tmp_tf.cpu_online = 1;
tmp_tf.cpu_num = num;
tmp_tf.name = name;
group = g_array_sized_new (FALSE, TRUE, sizeof(LttTracefile), 10);
g_datalist_id_set_data_full(&trace->tracefiles, name,
group, ltt_tracefile_group_destroy);
- mdata = allocate_marker_data();
- if (!mdata)
- g_error("Error in allocating marker data");
}
/* Add the per cpu tracefile to the named group */
if(num+1 > old_len)
group = g_array_set_size(group, num+1);
- g_assert(group->len > 0);
- if (!mdata)
- mdata = g_array_index (group, LttTracefile, 0).mdata;
-
g_array_index (group, LttTracefile, num) = tmp_tf;
g_array_index (group, LttTracefile, num).event.tracefile =
&g_array_index (group, LttTracefile, num);
- for (i = 0; i < group->len; i++)
- g_array_index (group, LttTracefile, i).mdata = mdata;
+ mdata = &g_array_index (group, LttTracefile, num).mdata;
+ *mdata = allocate_marker_data();
+ if (!*mdata)
+ g_error("Error in allocating marker data");
}
}