X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=a2403a77ab8d8906e18e59cb41d6a68684e2ba7a;hp=c369d8d36487ae79980a1caa747a79a4f2f916ec;hb=86b06ede131de636cd9ee62ea79d37f86e75c257;hpb=bcbfb8bf88ea9afbecd8a79708939fb8b79e5734 diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index c369d8d3..a2403a77 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -551,20 +551,15 @@ error: 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; @@ -600,8 +595,10 @@ void ctf_fini_pos(struct ctf_stream_pos *pos) 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); } /* @@ -1855,9 +1852,6 @@ int ctf_convert_index_timestamp(struct trace_descriptor *tdp) 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;