X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=formats%2Fctf%2Fctf.c;h=272e8c45f4a6dc22270e6e7286bc64b723f448be;hb=37fcdd1964a5e821b24da7641d34775b90b5c711;hp=c369d8d36487ae79980a1caa747a79a4f2f916ec;hpb=bcbfb8bf88ea9afbecd8a79708939fb8b79e5734;p=babeltrace.git diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index c369d8d3..272e8c45 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -560,11 +560,15 @@ void ctf_init_pos(struct ctf_stream_pos *pos, int fd, int open_flags) 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 +604,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 +1861,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;