X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=d60b4353fc2c0d9bbdaaac45fbfb7e1475dd3b1d;hp=f1fdba178f0a773d28a2286dae9eee133c29e929;hb=cd0058c96bdb3b32291f19899576978bb0fb6a19;hpb=f60efc0e475b3c2fca3b2afc584615f6c482c9e7 diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index f1fdba17..d60b4353 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -1267,6 +1267,7 @@ int create_stream_packet_index(struct ctf_trace *td, packet_index.timestamp_begin = 0; packet_index.timestamp_end = 0; packet_index.events_discarded = 0; + packet_index.events_discarded_len = 0; /* read and check header, set stream id (and check) */ if (file_stream->parent.trace_packet_header) { @@ -1903,35 +1904,14 @@ void ctf_close_trace(struct trace_descriptor *tdp) continue; for (j = 0; j < stream->streams->len; j++) { struct ctf_file_stream *file_stream; - file_stream = container_of(g_ptr_array_index(stream->streams, j), struct ctf_file_stream, parent); + file_stream = container_of(g_ptr_array_index(stream->streams, j), + struct ctf_file_stream, parent); ctf_close_file_stream(file_stream); } - - } - g_ptr_array_free(td->streams, TRUE); - } - - if (td->event_declarations) { - for (i = 0; i < td->event_declarations->len; i++) { - struct bt_ctf_event_decl *event; - - event = g_ptr_array_index(td->event_declarations, i); - if (event->context_decl) - g_ptr_array_free(event->context_decl, TRUE); - if (event->fields_decl) - g_ptr_array_free(event->fields_decl, TRUE); - if (event->packet_header_decl) - g_ptr_array_free(event->packet_header_decl, TRUE); - if (event->event_context_decl) - g_ptr_array_free(event->event_context_decl, TRUE); - if (event->event_header_decl) - g_ptr_array_free(event->event_header_decl, TRUE); - if (event->packet_context_decl) - g_ptr_array_free(event->packet_context_decl, TRUE); - g_free(event); } - g_ptr_array_free(td->event_declarations, TRUE); } + ctf_destroy_metadata(td); + close(td->dirfd); closedir(td->dir); g_free(td); } @@ -1956,6 +1936,7 @@ void ctf_set_handle(struct trace_descriptor *descriptor, td->handle = handle; } +static void __attribute__((constructor)) ctf_init(void) { int ret; @@ -1965,4 +1946,8 @@ void __attribute__((constructor)) ctf_init(void) assert(!ret); } -/* TODO: finalize */ +static +void __attribute__((destructor)) ctf_exit(void) +{ + bt_unregister_format(&ctf_format); +}