void ctf_init_pos(struct ctf_stream_pos *pos, int fd, int open_flags)
{
pos->fd = fd;
- pos->mmap_offset = 0;
- pos->packet_size = 0;
- pos->content_size = 0;
- pos->content_size_loc = NULL;
- pos->base_mma = NULL;
- pos->offset = 0;
- pos->dummy = false;
- pos->cur_index = 0;
- pos->packet_real_index = NULL;
- if (fd >= 0)
+ if (fd >= 0) {
pos->packet_cycles_index = g_array_new(FALSE, TRUE,
sizeof(struct packet_index));
- else
+ pos->packet_real_index = g_array_new(FALSE, TRUE,
+ sizeof(struct packet_index));
+ } else {
pos->packet_cycles_index = NULL;
+ pos->packet_real_index = NULL;
+ }
switch (open_flags & O_ACCMODE) {
case O_RDONLY:
pos->prot = PROT_READ;
assert(0);
}
}
- (void) g_array_free(pos->packet_cycles_index, TRUE);
- (void) g_array_free(pos->packet_real_index, TRUE);
+ if (pos->packet_cycles_index)
+ (void) g_array_free(pos->packet_cycles_index, TRUE);
+ if (pos->packet_real_index)
+ (void) g_array_free(pos->packet_real_index, TRUE);
}
/*
break;
}
case SEEK_SET:
+ packet_index = &g_array_index(pos->packet_cycles_index,
+ struct packet_index, index);
+ pos->last_events_discarded = packet_index->events_discarded;
pos->cur_index = index;
file_stream->parent.prev_real_timestamp = 0;
file_stream->parent.prev_real_timestamp_end = 0;
if (ret)
goto error_def;
/*
- * For now, only a single slock is supported.
+ * For now, only a single clock per trace is supported.
*/
file_stream->parent.current_clock = td->single_clock;
ret = create_stream_packet_index(td, file_stream);
goto error_index;
/*
- * For now, only a single slock is supported.
+ * For now, only a single clock per trace is supported.
*/
file_stream->parent.current_clock = td->single_clock;
cfs = container_of(stream, struct ctf_file_stream,
parent);
stream_pos = &cfs->pos;
- stream_pos->packet_real_index = g_array_new(FALSE, TRUE,
- sizeof(struct packet_index));
-
if (!stream_pos->packet_cycles_index)
continue;