Add missing generated tests to gitignore
[babeltrace.git] / lib / context.c
index 5820fb3e5533ba97693044ce0e419ca0382545d8..45aab34bdfc71c1b78bc9c409d42e70230b307b3 100644 (file)
@@ -137,14 +137,24 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,
        if (ret != 0)
                goto error;
 
-       ret = fmt->convert_index_timestamp(td);
-       if (ret < 0)
-               goto error;
+       if (fmt->convert_index_timestamp) {
+               ret = fmt->convert_index_timestamp(td);
+               if (ret < 0)
+                       goto error;
+       }
 
-       handle->real_timestamp_begin = fmt->timestamp_begin(td, handle, BT_CLOCK_REAL);
-       handle->real_timestamp_end = fmt->timestamp_end(td, handle, BT_CLOCK_REAL);
-       handle->cycles_timestamp_begin = fmt->timestamp_begin(td, handle, BT_CLOCK_CYCLES);
-       handle->cycles_timestamp_end = fmt->timestamp_end(td, handle, BT_CLOCK_CYCLES);
+       if (fmt->timestamp_begin)
+               handle->real_timestamp_begin = fmt->timestamp_begin(td,
+                               handle, BT_CLOCK_REAL);
+       if (fmt->timestamp_end)
+               handle->real_timestamp_end = fmt->timestamp_end(td, handle,
+                               BT_CLOCK_REAL);
+       if (fmt->timestamp_begin)
+               handle->cycles_timestamp_begin = fmt->timestamp_begin(td,
+                               handle, BT_CLOCK_CYCLES);
+       if (fmt->timestamp_end)
+               handle->cycles_timestamp_end = fmt->timestamp_end(td, handle,
+                               BT_CLOCK_CYCLES);
 
        return handle->id;
 
@@ -217,6 +227,8 @@ void remove_trace_handle(struct bt_trace_handle *handle)
 {
        int ret;
 
+       if (!handle->td->ctx)
+               return;
        /* Remove from containers */
        bt_trace_collection_remove(handle->td->ctx->tc, handle->td);
        /* Close the trace */
This page took 0.022859 seconds and 4 git commands to generate.