Add an allocation function for ust stream
authorDavid Goulet <dgoulet@efficios.com>
Mon, 21 Jan 2013 20:49:45 +0000 (15:49 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 21 Jan 2013 20:52:28 +0000 (15:52 -0500)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/ust-app.c

index 397a2dfab29b5f2106f1a235a4ce1a7bfb7f0a7b..f6f2c64ae9895958af62592b15cccee9b42527ff 100644 (file)
@@ -378,6 +378,28 @@ error:
        return NULL;
 }
 
+/*
+ * Allocate and initialize a UST app stream.
+ *
+ * Return newly allocated stream pointer or NULL on error.
+ */
+static struct ust_app_stream *alloc_ust_app_stream(void)
+{
+       struct ust_app_stream *stream = NULL;
+
+       stream = zmalloc(sizeof(*stream));
+       if (stream == NULL) {
+               PERROR("zmalloc ust app stream");
+               goto error;
+       }
+
+       /* Zero could be a valid value for a handle so flag it to -1. */
+       stream->handle = -1;
+
+error:
+       return stream;
+}
+
 /*
  * Alloc new UST app event.
  */
@@ -2362,9 +2384,8 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
                /* Create all streams */
                while (1) {
                        /* Create UST stream */
-                       ustream = zmalloc(sizeof(*ustream));
+                       ustream = alloc_ust_app_stream();
                        if (ustream == NULL) {
-                               PERROR("zmalloc ust stream");
                                goto error_rcu_unlock;
                        }
 
This page took 0.02887 seconds and 4 git commands to generate.