#include <babeltrace/ctf-writer/functor-internal.h>
#include <babeltrace/ctf-ir/stream-class-internal.h>
#include <babeltrace/ctf-ir/stream-internal.h>
+#include <babeltrace/ctf-ir/ref.h>
+#include <babeltrace/ctf-ir/common-internal.h>
#include <babeltrace/compiler.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
static
-void bt_ctf_writer_destroy(struct bt_ctf_ref *ref);
+void bt_ctf_writer_destroy(struct bt_ref *ref);
static
int create_stream_file(struct bt_ctf_writer *writer,
struct bt_ctf_stream *stream);
goto error;
}
- bt_ctf_ref_init(&writer->ref_count);
+ bt_ctf_base_init(writer, bt_ctf_writer_destroy);
writer->path = g_string_new(path);
if (!writer->path) {
goto error_destroy;
error_destroy:
unlinkat(writer->trace_dir_fd, "metadata", 0);
- bt_ctf_writer_destroy(&writer->ref_count);
+ bt_ctf_writer_destroy(&writer->base.ref_count);
writer = NULL;
error:
return writer;
}
-void bt_ctf_writer_destroy(struct bt_ctf_ref *ref)
+void bt_ctf_writer_destroy(struct bt_ref *ref)
{
struct bt_ctf_writer *writer;
+ struct bt_ctf_base *base;
if (!ref) {
return;
}
- writer = container_of(ref, struct bt_ctf_writer, ref_count);
+ base = container_of(ref, struct bt_ctf_base, ref_count);
+ writer = container_of(base, struct bt_ctf_writer, base);
bt_ctf_writer_flush_metadata(writer);
if (writer->path) {
g_string_free(writer->path, TRUE);
void bt_ctf_writer_get(struct bt_ctf_writer *writer)
{
- if (!writer) {
- return;
- }
-
- bt_ctf_ref_get(&writer->ref_count);
+ bt_ctf_get(writer);
}
void bt_ctf_writer_put(struct bt_ctf_writer *writer)
{
- if (!writer) {
- return;
- }
-
- bt_ctf_ref_put(&writer->ref_count, bt_ctf_writer_destroy);
+ bt_ctf_put(writer);
}
static