-// Obtain the range of the trace (i.e. "start time" and "end time")
-// Note : this method is quite heavy to use!
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange(JNIEnv* env, jobject jobj, jlong trace_ptr, jobject jstart_time, jobject jend_time) {
- LttTrace* newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
+
+/* g_list_data function for the "for_each" call in Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange */
+/* used to save the current timestamp for each tracefile */
+void g_datalist_foreach_saveTracefilesTime(GQuark name, gpointer data, gpointer user_data) {
+ struct saveTimeArgs *args = (struct saveTimeArgs*)user_data;
+
+ GArray *tracefile_array = (GArray*)data;
+ GArray *save_array = args->saveTimeArray;
+
+ LttTracefile *tracefile;
+ struct saveTimeAndTracefile *savedData;
+
+ unsigned int i;
+ for (i=0; i<tracefile_array->len; i++) {
+ tracefile = &g_array_index(tracefile_array, LttTracefile, i);
+
+ /* Allocate a new LttTime for each tracefile (so it won't change if the tracefile seek somewhere else) */
+ savedData = (struct saveTimeAndTracefile*)malloc( sizeof(struct saveTimeAndTracefile) );
+ savedData->time.tv_sec = tracefile->event.event_time.tv_sec;
+ savedData->time.tv_nsec = tracefile->event.event_time.tv_nsec;
+ savedData->tracefile = tracefile;
+ /* Append the saved data to the array */
+ g_array_append_val(save_array, savedData);
+ }
+}
+
+
+/* Obtain the range of the trace (i.e. "start time" and "end time") */
+/* Note : This function, unlike ltt_trace_time_span_get, is assured to return all tracefiles to their correct position after operation */
+/* NOTE : this method is quite heavy to use!!! */
+JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange(JNIEnv *env, jobject jobj, jlong trace_ptr, jobject jstart_time, jobject jend_time) {
+ LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);