Allow NULL clock name
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 25 Aug 2016 18:31:25 +0000 (14:31 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 17:41:38 +0000 (13:41 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/clock.c
include/babeltrace/ctf-ir/clock.h

index 002b72058fd4d6a14731d1581a7ff62720b8a5fa..738f2d80977a6a0eb0ee5b7195594493354b08a4 100644 (file)
 static
 void bt_ctf_clock_destroy(struct bt_object *obj);
 
-struct bt_ctf_clock *bt_ctf_clock_create_empty(void)
-{
-       struct bt_ctf_clock *clock = g_new0(
-               struct bt_ctf_clock, 1);
-
-       if (!clock) {
-               goto end;
-       }
-
-       clock->precision = 1;
-       clock->frequency = 1000000000;
-       bt_object_init(clock, bt_ctf_clock_destroy);
-end:
-       return clock;
-}
-
 BT_HIDDEN
 bool bt_ctf_clock_is_valid(struct bt_ctf_clock *clock)
 {
@@ -91,16 +75,21 @@ end:
 struct bt_ctf_clock *bt_ctf_clock_create(const char *name)
 {
        int ret;
-       struct bt_ctf_clock *clock = NULL;
+       struct bt_ctf_clock *clock = g_new0(struct bt_ctf_clock, 1);
 
-       clock = bt_ctf_clock_create_empty();
        if (!clock) {
                goto error;
        }
 
-       ret = bt_ctf_clock_set_name(clock, name);
-       if (ret) {
-               goto error;
+       clock->precision = 1;
+       clock->frequency = 1000000000;
+       bt_object_init(clock, bt_ctf_clock_destroy);
+
+       if (name) {
+               ret = bt_ctf_clock_set_name(clock, name);
+               if (ret) {
+                       goto error;
+               }
        }
 
        ret = bt_uuid_generate(clock->uuid);
index 5858a711ef7b0c00e0f02d8c95f2eea662794c46..93d4cbef5a6c6d0d0b9abf3bb8f122d225071477 100644 (file)
@@ -43,16 +43,13 @@ struct bt_ctf_clock;
  *
  * Allocate a new clock setting its reference count to 1.
  *
- * @param name Name of the clock (will be copied).
+ * @param name Name of the clock (will be copied); can be set to NULL
+ *             for nameless clocks.
  *
  * Returns an allocated clock on success, NULL on error.
  */
 extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
 
-extern struct bt_ctf_clock *bt_ctf_clock_create_empty(void);
-
-extern int bt_ctf_clock_set_name(struct bt_ctf_clock *clock, const char *name);
-
 /*
  * bt_ctf_clock_get_name: get a clock's name.
  *
This page took 0.026243 seconds and 4 git commands to generate.