static void trace_text(FILE *input, int output) { struct ctf_stream_pos pos; ssize_t len; char *line = NULL, *nl; size_t linesize; int ret; memset(&pos, 0, sizeof(pos)); ret = ctf_init_pos(&pos, NULL, output, O_RDWR); if (ret) { fprintf(stderr, "Error in ctf_init_pos\n"); return; } write_packet_header(&pos, s_uuid); write_packet_context(&pos); for (;;) { len = getline(&line, &linesize, input); if (len < 0) break; nl = strrchr(line, '\n'); if (nl) { *nl = '\0'; trace_string(line, &pos, nl - line + 1); } else { trace_string(line, &pos, strlen(line) + 1); } } ret = ctf_fini_pos(&pos); if (ret) { fprintf(stderr, "Error in ctf_fini_pos\n"); } }
static void bt_ctf_stream_destroy(struct bt_object *obj) { struct bt_ctf_stream *stream; stream = container_of(obj, struct bt_ctf_stream, base); ctf_fini_pos(&stream->pos); if (stream->pos.fd >= 0 && close(stream->pos.fd)) { perror("close"); } if (stream->events) { g_ptr_array_free(stream->events, TRUE); } if (stream->name) { g_string_free(stream->name, TRUE); } if (stream->clock_values) { g_hash_table_destroy(stream->clock_values); } bt_put(stream->packet_header); bt_put(stream->packet_context); g_free(stream); }